diff --git a/src/main/java/io/castle/client/Castle.java b/src/main/java/io/castle/client/Castle.java index a87ceeb..61cc4ee 100644 --- a/src/main/java/io/castle/client/Castle.java +++ b/src/main/java/io/castle/client/Castle.java @@ -38,6 +38,19 @@ public class Castle { public static final String URL_RECOVER = "/v1/users/%s/recover"; + public static final String URL_LISTS = "/v1/lists"; + public static final String URL_LISTS_ID = "/v1/lists/%s"; + public static final String URL_LISTS_SEARCH = "/v1/lists/query"; + + public static final String URL_LISTS_ITEMS = "/v1/lists/%s/items"; + public static final String URL_LISTS_ITEMS_BATCH = "/v1/lists/%s/items/batch"; + public static final String URL_LISTS_ITEMS_SEARCH = "/v1/lists/%s/items/query"; + public static final String URL_LISTS_ITEMS_COUNT = "/v1/lists/%s/items/count"; + public static final String URL_LISTS_ITEMS_UPDATE = "/v1/lists/%s/items/%s"; + public static final String URL_LISTS_ITEMS_GET = "/v1/lists/%s/items/%s"; + public static final String URL_LISTS_ITEMS_ARCHIVE = "/v1/lists/%s/items/%s/archive"; + public static final String URL_LISTS_ITEMS_UNARCHIVE = "/v1/lists/%s/items/%s/unarchive"; + public static final String KEY_EVENT = "event"; public static final String KEY_USER = "user"; public static final String KEY_STATUS = "status"; diff --git a/src/main/java/io/castle/client/api/CastleApi.java b/src/main/java/io/castle/client/api/CastleApi.java index 41ea4b6..ae782d8 100644 --- a/src/main/java/io/castle/client/api/CastleApi.java +++ b/src/main/java/io/castle/client/api/CastleApi.java @@ -6,6 +6,7 @@ import io.castle.client.model.generated.*; import javax.annotation.Nullable; +import java.util.List; /** * Contains methods for calling the Castle API and the settings needed to properly make such a request. @@ -316,6 +317,109 @@ public interface CastleApi { */ FilterAndRiskResponse risk(Risk payload); + /** + * Makes a sync POST request to the list endpoint. + * + * @param payload Event parameters + * @return + */ + ListResponse createList(ListRequest payload); + + /** + * Makes a sync GET request to the list endpoint. + * @return + */ + List listAllLists(); + + /** + * Makes a sync GET request to the list endpoint. + * + * @param listId List ID + * @return + */ + ListResponse list(String listId); + + /** + * Makes a sync PUT request to the list endpoint. + * + * @param listId List ID + * @param payload Event parameters + * @return + */ + ListResponse updateList(String listId, ListRequest payload); + + /** + * Makes a sync DELETE request to the list endpoint. + * + * @param listId List ID + * @return + */ + CastleResponse deleteList(String listId); + + /** + * Makes a sync POST request to the list endpoint. + * + * @param payload Search parameters + * @return + */ + List searchLists(ListQuery payload); + + /** + * Makes a sync POST request to the list item endpoint. + * + * @param listId List ID + * @param payload Event parameters + * @return + */ + ListItem createListItem(String listId, ListItemRequest payload); + + /** + * Makes a sync POST request to the list item endpoint. + * + * @param id List ID + * @param payload Event parameters + * @return + */ + ListItemsBatchResponse createOrUpdateListItems(String id, ListItemsBatchRequest payload); + + /** + * Makes a sync GET request to the list item endpoint. + * + * @return + */ + List searchListItems(String listId, ListItemQuery payload); + + /** + * Makes a sync GET request to the list item endpoint. + * + * @param listId List ID + * @param payload Event parameters + * @return + */ + ListItemListCount countListItems(String listId, ListItemQuery payload); + + /** + * Makes a sync GET request to the list item endpoint. + * + * @param listId List ID + * @param itemid Item ID + * @return + */ + ListItem updateListItem(String listId, String itemid, ListItemRequest payload); + + /** + * Makes a sync GET request to the list item endpoint. + * + * @param listId List ID + * @param itemid Item ID + * @return + */ + ListItem getListItem(String listId, String itemid); + + CastleResponse archiveListItem(String listId, String itemid); + + CastleResponse unarchiveListItem(String listId, String itemid); + /** * Makes a sync POST request to the filter endpoint. * diff --git a/src/main/java/io/castle/client/internal/CastleApiImpl.java b/src/main/java/io/castle/client/internal/CastleApiImpl.java index d189bf0..aaa9652 100644 --- a/src/main/java/io/castle/client/internal/CastleApiImpl.java +++ b/src/main/java/io/castle/client/internal/CastleApiImpl.java @@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableMap; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import com.google.gson.reflect.TypeToken; import io.castle.client.Castle; import io.castle.client.api.CastleApi; import io.castle.client.internal.backend.RestApi; @@ -13,13 +14,12 @@ import io.castle.client.internal.utils.Timestamp; import io.castle.client.internal.utils.VerdictBuilder; import io.castle.client.model.*; -import io.castle.client.model.generated.Filter; -import io.castle.client.model.generated.FilterAndRiskResponse; -import io.castle.client.model.generated.Log; -import io.castle.client.model.generated.Risk; +import io.castle.client.model.generated.*; import jakarta.servlet.http.HttpServletRequest; import javax.annotation.Nullable; +import java.lang.reflect.Type; +import java.util.List; public class CastleApiImpl implements CastleApi { @@ -332,6 +332,127 @@ public FilterAndRiskResponse risk(Risk payload) { return configuration.getModel().getGson().fromJson(castleResponse.json(), FilterAndRiskResponse.class); } + @Override + public ListResponse createList(ListRequest payload) { + Preconditions.checkNotNull(payload); + RestApi restApi = configuration.getRestApiFactory().buildBackend(); + CastleResponse castleResponse = restApi.post(Castle.URL_LISTS, payload); + return configuration.getModel().getGson().fromJson(castleResponse.json(), ListResponse.class); + } + + @Override + public CastleResponse deleteList(String id) { + Preconditions.checkNotNull(id); + RestApi restApi = configuration.getRestApiFactory().buildBackend(); + return restApi.delete(String.format(Castle.URL_LISTS_ID, id)); + } + + @Override + public List searchLists(ListQuery payload) { + Preconditions.checkNotNull(payload); + RestApi restApi = configuration.getRestApiFactory().buildBackend(); + CastleResponse castleResponse = restApi.post(Castle.URL_LISTS_SEARCH, payload); + Type listType = new TypeToken>(){}.getType(); + return configuration.getModel().getGson().fromJson(castleResponse.json(), listType); + } + + @Override + public List listAllLists() { + RestApi restApi = configuration.getRestApiFactory().buildBackend(); + CastleResponse castleResponse = restApi.get(Castle.URL_LISTS); + Type listType = new TypeToken>(){}.getType(); + return configuration.getModel().getGson().fromJson(castleResponse.json(), listType); + } + + @Override + public ListResponse updateList(String id, ListRequest payload) { + Preconditions.checkNotNull(id); + Preconditions.checkNotNull(payload); + RestApi restApi = configuration.getRestApiFactory().buildBackend(); + CastleResponse castleResponse = restApi.put(String.format(Castle.URL_LISTS_ID, id), payload); + return configuration.getModel().getGson().fromJson(castleResponse.json(), ListResponse.class); + } + + @Override + public ListResponse list(String id) { + Preconditions.checkNotNull(id); + RestApi restApi = configuration.getRestApiFactory().buildBackend(); + CastleResponse castleResponse = restApi.get(String.format(Castle.URL_LISTS_ID, id)); + return configuration.getModel().getGson().fromJson(castleResponse.json(), ListResponse.class); + } + + @Override + public ListItem createListItem(String id, ListItemRequest payload) { + Preconditions.checkNotNull(id); + Preconditions.checkNotNull(payload); + RestApi restApi = configuration.getRestApiFactory().buildBackend(); + CastleResponse castleResponse = restApi.post(String.format(Castle.URL_LISTS_ITEMS, id), payload); + return configuration.getModel().getGson().fromJson(castleResponse.json(), ListItem.class); + } + + @Override + public ListItemsBatchResponse createOrUpdateListItems(String id, ListItemsBatchRequest payload) { + Preconditions.checkNotNull(id); + Preconditions.checkNotNull(payload); + RestApi restApi = configuration.getRestApiFactory().buildBackend(); + CastleResponse castleResponse = restApi.post(String.format(Castle.URL_LISTS_ITEMS_BATCH, id), payload); + return configuration.getModel().getGson().fromJson(castleResponse.json(), ListItemsBatchResponse.class); + } + + @Override + public List searchListItems(String id, ListItemQuery payload) { + Preconditions.checkNotNull(id); + Preconditions.checkNotNull(payload); + RestApi restApi = configuration.getRestApiFactory().buildBackend(); + CastleResponse castleResponse = restApi.post(String.format(Castle.URL_LISTS_ITEMS_SEARCH, id), payload); + Type listType = new TypeToken>(){}.getType(); + return configuration.getModel().getGson().fromJson(castleResponse.json(), listType); + } + + @Override + public ListItemListCount countListItems(String id, ListItemQuery payload) { + Preconditions.checkNotNull(id); + Preconditions.checkNotNull(payload); + RestApi restApi = configuration.getRestApiFactory().buildBackend(); + CastleResponse castleResponse = restApi.post(String.format(Castle.URL_LISTS_ITEMS_COUNT, id), payload); + return configuration.getModel().getGson().fromJson(castleResponse.json(), ListItemListCount.class); + } + + @Override + public ListItem updateListItem(String listId, String itemId, ListItemRequest payload) { + Preconditions.checkNotNull(listId); + Preconditions.checkNotNull(itemId); + Preconditions.checkNotNull(payload); + RestApi restApi = configuration.getRestApiFactory().buildBackend(); + CastleResponse castleResponse = restApi.post(String.format(Castle.URL_LISTS_ITEMS_UPDATE, listId, itemId), payload); + return configuration.getModel().getGson().fromJson(castleResponse.json(), ListItem.class); + } + + @Override + public ListItem getListItem(String listId, String itemId) { + Preconditions.checkNotNull(listId); + Preconditions.checkNotNull(itemId); + RestApi restApi = configuration.getRestApiFactory().buildBackend(); + CastleResponse castleResponse = restApi.get(String.format(Castle.URL_LISTS_ITEMS_GET, listId, itemId)); + return configuration.getModel().getGson().fromJson(castleResponse.json(), ListItem.class); + } + + @Override + public CastleResponse archiveListItem(String listId, String itemId) { + Preconditions.checkNotNull(listId); + Preconditions.checkNotNull(itemId); + RestApi restApi = configuration.getRestApiFactory().buildBackend(); + return restApi.delete(String.format(Castle.URL_LISTS_ITEMS_ARCHIVE, listId, itemId)); + } + + @Override + public CastleResponse unarchiveListItem(String listId, String itemId) { + Preconditions.checkNotNull(listId); + Preconditions.checkNotNull(itemId); + RestApi restApi = configuration.getRestApiFactory().buildBackend(); + return restApi.put(String.format(Castle.URL_LISTS_ITEMS_UNARCHIVE, listId, itemId)); + } + @Override public CastleResponse filter(ImmutableMap payload) { Preconditions.checkNotNull(payload); diff --git a/src/main/java/io/castle/client/model/generated/Address.java b/src/main/java/io/castle/client/model/generated/Address.java index 022985e..45dab70 100755 --- a/src/main/java/io/castle/client/model/generated/Address.java +++ b/src/main/java/io/castle/client/model/generated/Address.java @@ -195,7 +195,6 @@ public int hashCode() { return Objects.hash(line1, line2, city, countryCode, regionCode, postalCode, fingerprint); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/io/castle/client/model/generated/AuthorType.java b/src/main/java/io/castle/client/model/generated/AuthorType.java new file mode 100755 index 0000000..3c6c5d9 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/AuthorType.java @@ -0,0 +1,77 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * OpenAPI spec version: 1 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package io.castle.client.model.generated; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +import java.io.IOException; + +/** + * Gets or Sets AuthorType + */ +@JsonAdapter(AuthorType.Adapter.class) +public enum AuthorType { + @SerializedName("$analyst_email") + ANALYST_EMAIL("$analyst_email"), + @SerializedName("$castle_dashboard_user") + CASTLE_DASHBOARD_USER("$castle_dashboard_user"), + @SerializedName("$castle_policy") + CASTLE_POLICY("$castle_policy"), + @SerializedName("$user") + USER("$user"), + @SerializedName("$user_email") + USER_EMAIL("$user_email"), + @SerializedName("$other") + OTHER("$other"); + + private String value; + + AuthorType(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static AuthorType fromValue(String input) { + for (AuthorType b : AuthorType.values()) { + if (b.value.equals(input)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final AuthorType enumeration) throws IOException { + jsonWriter.value(String.valueOf(enumeration.getValue())); + } + + @Override + public AuthorType read(final JsonReader jsonReader) throws IOException { + Object value = jsonReader.nextString(); + return AuthorType.fromValue((String)(value)); + } + } +} diff --git a/src/main/java/io/castle/client/model/generated/BaseItem.java b/src/main/java/io/castle/client/model/generated/BaseItem.java new file mode 100755 index 0000000..0e1b2a7 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/BaseItem.java @@ -0,0 +1,179 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * OpenAPI spec version: 1 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package io.castle.client.model.generated; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.threeten.bp.OffsetDateTime; + +import java.util.Objects; +/** + * List Item + */ +@ApiModel(description = "List Item") +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2025-01-20T18:58:06.855017776Z[GMT]") + +public class BaseItem { + @SerializedName("primary_value") + private String primaryValue = null; + + @SerializedName("secondary_value") + private String secondaryValue = null; + + @SerializedName("comment") + private String comment = null; + + @SerializedName("author") + private ListItemAuthor author = null; + + @SerializedName("auto_archives_at") + private OffsetDateTime autoArchivesAt = null; + + public BaseItem primaryValue(String primaryValue) { + this.primaryValue = primaryValue; + return this; + } + + /** + * Value of the `primary_field` as described by the List definition. For example, if `primary_field` is configured to be the Event `user.id`, the `primary_value` on the List Item referes to the actual User ID value. + * @return primaryValue + **/ + @ApiModelProperty(example = "A04t7AcfSA69cBTTusx0RQ", value = "Value of the `primary_field` as described by the List definition. For example, if `primary_field` is configured to be the Event `user.id`, the `primary_value` on the List Item referes to the actual User ID value.") + public String getPrimaryValue() { + return primaryValue; + } + + public void setPrimaryValue(String primaryValue) { + this.primaryValue = primaryValue; + } + + public BaseItem secondaryValue(String secondaryValue) { + this.secondaryValue = secondaryValue; + return this; + } + + /** + * Optional secondary value. If this value is set, it means that for a List Item to match an Event, both the `primary_value` and `secondary_value` must match. + * @return secondaryValue + **/ + @ApiModelProperty(example = "2ee938c8-24c2-4c26-9d25-19511dd75029", value = "Optional secondary value. If this value is set, it means that for a List Item to match an Event, both the `primary_value` and `secondary_value` must match.") + public String getSecondaryValue() { + return secondaryValue; + } + + public void setSecondaryValue(String secondaryValue) { + this.secondaryValue = secondaryValue; + } + + public BaseItem comment(String comment) { + this.comment = comment; + return this; + } + + /** + * An arbitrary string that can be used to eg. explain why this List Item was created. Often useful to display to other users. + * @return comment + **/ + @ApiModelProperty(example = "Fradulent user found through manual inspection", value = "An arbitrary string that can be used to eg. explain why this List Item was created. Often useful to display to other users.") + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + public BaseItem author(ListItemAuthor author) { + this.author = author; + return this; + } + + /** + * Get author + * @return author + **/ + @ApiModelProperty(value = "") + public ListItemAuthor getAuthor() { + return author; + } + + public void setAuthor(ListItemAuthor author) { + this.author = author; + } + + public BaseItem autoArchivesAt(OffsetDateTime autoArchivesAt) { + this.autoArchivesAt = autoArchivesAt; + return this; + } + + /** + * Time after which a the List Item will be automatically archived and no longer matched against each event. A value of `null` means auto archivation is disabled and the record will stay active in the list forever. + * @return autoArchivesAt + **/ + @ApiModelProperty(example = "2021-09-27T16:46:38.313Z", value = "Time after which a the List Item will be automatically archived and no longer matched against each event. A value of `null` means auto archivation is disabled and the record will stay active in the list forever.") + public OffsetDateTime getAutoArchivesAt() { + return autoArchivesAt; + } + + public void setAutoArchivesAt(OffsetDateTime autoArchivesAt) { + this.autoArchivesAt = autoArchivesAt; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BaseItem baseItem = (BaseItem) o; + return Objects.equals(this.primaryValue, baseItem.primaryValue) && + Objects.equals(this.secondaryValue, baseItem.secondaryValue) && + Objects.equals(this.comment, baseItem.comment) && + Objects.equals(this.author, baseItem.author) && + Objects.equals(this.autoArchivesAt, baseItem.autoArchivesAt); + } + + @Override + public int hashCode() { + return Objects.hash(primaryValue, secondaryValue, comment, author, autoArchivesAt); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BaseItem {\n"); + sb.append(" primaryValue: ").append(toIndentedString(primaryValue)).append("\n"); + sb.append(" secondaryValue: ").append(toIndentedString(secondaryValue)).append("\n"); + sb.append(" comment: ").append(toIndentedString(comment)).append("\n"); + sb.append(" author: ").append(toIndentedString(author)).append("\n"); + sb.append(" autoArchivesAt: ").append(toIndentedString(autoArchivesAt)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/io/castle/client/model/generated/BaseList.java b/src/main/java/io/castle/client/model/generated/BaseList.java new file mode 100755 index 0000000..d6dc4aa --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/BaseList.java @@ -0,0 +1,160 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * OpenAPI spec version: 1 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package io.castle.client.model.generated; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + +/** + * List + */ +@ApiModel(description = "List") +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2025-01-20T18:58:06.855017776Z[GMT]") + +public class BaseList { + @SerializedName("name") + private String name = null; + + @SerializedName("description") + private String description = null; + + @SerializedName("color") + private ListColor color = null; + + @SerializedName("default_item_archivation_time") + private Integer defaultItemArchivationTime = null; + + public BaseList name(String name) { + this.name = name; + return this; + } + + /** + * Name of the List + * @return name + **/ + @ApiModelProperty(example = "Malicious IPs", value = "Name of the List") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public BaseList description(String description) { + this.description = description; + return this; + } + + /** + * Description of the List + * @return description + **/ + @ApiModelProperty(example = "We block these IPs from withdrawing funds. Please be careful.", value = "Description of the List") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public BaseList color(ListColor color) { + this.color = color; + return this; + } + + /** + * Get color + * @return color + **/ + @ApiModelProperty(value = "") + public ListColor getColor() { + return color; + } + + public void setColor(ListColor color) { + this.color = color; + } + + public BaseList defaultItemArchivationTime(Integer defaultItemArchivationTime) { + this.defaultItemArchivationTime = defaultItemArchivationTime; + return this; + } + + /** + * Default time, in seconds, after which Items in this List automatically gets archived after they are created. It is possible to override this value when creating the individual List Items + * minimum: 1 + * maximum: 63113904 + * @return defaultItemArchivationTime + **/ + @ApiModelProperty(example = "2592000", value = "Default time, in seconds, after which Items in this List automatically gets archived after they are created. It is possible to override this value when creating the individual List Items") + public int getDefaultItemArchivationTime() { + return defaultItemArchivationTime; + } + + public void setDefaultItemArchivationTime(Integer defaultItemArchivationTime) { + this.defaultItemArchivationTime = defaultItemArchivationTime; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BaseList baseList = (BaseList) o; + return Objects.equals(this.name, baseList.name) && + Objects.equals(this.description, baseList.description) && + Objects.equals(this.color, baseList.color) && + Objects.equals(this.defaultItemArchivationTime, baseList.defaultItemArchivationTime); + } + + @Override + public int hashCode() { + return Objects.hash(name, description, color, defaultItemArchivationTime); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BaseList {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).append("\n"); + sb.append(" defaultItemArchivationTime: ").append(toIndentedString(defaultItemArchivationTime)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/io/castle/client/model/generated/BaseListItemQueryFilter.java b/src/main/java/io/castle/client/model/generated/BaseListItemQueryFilter.java new file mode 100644 index 0000000..e0bcb1c --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/BaseListItemQueryFilter.java @@ -0,0 +1,4 @@ +package io.castle.client.model.generated; + +public class BaseListItemQueryFilter { +} diff --git a/src/main/java/io/castle/client/model/generated/BaseListQueryFilter.java b/src/main/java/io/castle/client/model/generated/BaseListQueryFilter.java new file mode 100644 index 0000000..641c6a3 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/BaseListQueryFilter.java @@ -0,0 +1,4 @@ +package io.castle.client.model.generated; + +public class BaseListQueryFilter { +} diff --git a/src/main/java/io/castle/client/model/generated/Behavior.java b/src/main/java/io/castle/client/model/generated/Behavior.java index 61c1db3..86d4be7 100755 --- a/src/main/java/io/castle/client/model/generated/Behavior.java +++ b/src/main/java/io/castle/client/model/generated/Behavior.java @@ -62,12 +62,10 @@ public int hashCode() { return Objects.hash(fingerprint); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class FilterAndRiskResponseBehavior {\n"); - sb.append(" fingerprint: ").append(toIndentedString(fingerprint)).append("\n"); sb.append("}"); return sb.toString(); diff --git a/src/main/java/io/castle/client/model/generated/ChangedChangesetEntry.java b/src/main/java/io/castle/client/model/generated/ChangedChangesetEntry.java index 113a9f8..b403e75 100644 --- a/src/main/java/io/castle/client/model/generated/ChangedChangesetEntry.java +++ b/src/main/java/io/castle/client/model/generated/ChangedChangesetEntry.java @@ -55,11 +55,10 @@ public int hashCode() { @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ChangedChangesetEntry {\n"); - sb.append(" changed: ").append(toIndentedString(changed)).append("\n"); - sb.append("}"); - return sb.toString(); + String sb = "class ChangedChangesetEntry {\n" + + " changed: " + toIndentedString(changed) + "\n" + + "}"; + return sb; } /** diff --git a/src/main/java/io/castle/client/model/generated/Changeset.java b/src/main/java/io/castle/client/model/generated/Changeset.java index 2779fa9..93d5d5d 100644 --- a/src/main/java/io/castle/client/model/generated/Changeset.java +++ b/src/main/java/io/castle/client/model/generated/Changeset.java @@ -192,16 +192,15 @@ public int hashCode() { @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Changeset {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" password: ").append(toIndentedString(password)).append("\n"); - sb.append(" email: ").append(toIndentedString(email)).append("\n"); - sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); - sb.append(" authenticationMethodType: ").append(toIndentedString(authenticationMethodType)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append("}"); - return sb.toString(); + String sb = "class Changeset {\n" + + " " + toIndentedString(super.toString()) + "\n" + + " password: " + toIndentedString(password) + "\n" + + " email: " + toIndentedString(email) + "\n" + + " phone: " + toIndentedString(phone) + "\n" + + " authenticationMethodType: " + toIndentedString(authenticationMethodType) + "\n" + + " name: " + toIndentedString(name) + "\n" + + "}"; + return sb; } /** diff --git a/src/main/java/io/castle/client/model/generated/ChangesetEntry.java b/src/main/java/io/castle/client/model/generated/ChangesetEntry.java index e2738a3..246f5fc 100644 --- a/src/main/java/io/castle/client/model/generated/ChangesetEntry.java +++ b/src/main/java/io/castle/client/model/generated/ChangesetEntry.java @@ -105,12 +105,11 @@ public int hashCode() { @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ChangesetEntry {\n"); - sb.append(" from: ").append(toIndentedString(from)).append("\n"); - sb.append(" to: ").append(toIndentedString(to)).append("\n"); - sb.append("}"); - return sb.toString(); + String sb = "class ChangesetEntry {\n" + + " from: " + toIndentedString(from) + "\n" + + " to: " + toIndentedString(to) + "\n" + + "}"; + return sb; } /** diff --git a/src/main/java/io/castle/client/model/generated/DeviceHardwareDisplay.java b/src/main/java/io/castle/client/model/generated/DeviceHardwareDisplay.java index 1db35f6..c9cd7d3 100755 --- a/src/main/java/io/castle/client/model/generated/DeviceHardwareDisplay.java +++ b/src/main/java/io/castle/client/model/generated/DeviceHardwareDisplay.java @@ -84,7 +84,6 @@ public int hashCode() { return Objects.hash(width, height); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/io/castle/client/model/generated/DeviceScreen.java b/src/main/java/io/castle/client/model/generated/DeviceScreen.java index cceb643..f25da37 100755 --- a/src/main/java/io/castle/client/model/generated/DeviceScreen.java +++ b/src/main/java/io/castle/client/model/generated/DeviceScreen.java @@ -84,12 +84,10 @@ public int hashCode() { return Objects.hash(screen, orientation); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class DeviceScreen {\n"); - sb.append(" screen: ").append(toIndentedString(screen)).append("\n"); sb.append(" orientation: ").append(toIndentedString(orientation)).append("\n"); sb.append("}"); diff --git a/src/main/java/io/castle/client/model/generated/EventParams.java b/src/main/java/io/castle/client/model/generated/EventParams.java index a1947b3..900a000 100755 --- a/src/main/java/io/castle/client/model/generated/EventParams.java +++ b/src/main/java/io/castle/client/model/generated/EventParams.java @@ -107,7 +107,6 @@ public int hashCode() { return Objects.hash(email, phone, username); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/io/castle/client/model/generated/FilterAndRiskResponse.java b/src/main/java/io/castle/client/model/generated/FilterAndRiskResponse.java index 3531f4e..f8c772c 100755 --- a/src/main/java/io/castle/client/model/generated/FilterAndRiskResponse.java +++ b/src/main/java/io/castle/client/model/generated/FilterAndRiskResponse.java @@ -491,12 +491,10 @@ public int hashCode() { return Objects.hash(risk, scores, policy, signals, metrics, device, id, name, type, status, createdAt, authenticated, authenticationMethod, email, endpoint, ip, params, product, sdks, session, user, behavior, properties); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class FilterAndRiskResponse {\n"); - sb.append(" risk: ").append(toIndentedString(risk)).append("\n"); sb.append(" scores: ").append(toIndentedString(scores)).append("\n"); sb.append(" policy: ").append(toIndentedString(policy)).append("\n"); diff --git a/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseEmail.java b/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseEmail.java index ef9e1a2..b60c135 100755 --- a/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseEmail.java +++ b/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseEmail.java @@ -20,7 +20,7 @@ /** * User Email Object */ -@ApiModel(value = "User Email Object") +@ApiModel(description = "User Email Object") @javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2025-01-20T18:58:06.855017776Z[GMT]") public class FilterAndRiskResponseEmail { @@ -151,12 +151,10 @@ public int hashCode() { return Objects.hash(normalized, domain, disposable, unreachable, domainDetails); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class FilterAndRiskResponseEmail {\n"); - sb.append(" normalized: ").append(toIndentedString(normalized)).append("\n"); sb.append(" domain: ").append(toIndentedString(domain)).append("\n"); sb.append(" disposable: ").append(toIndentedString(disposable)).append("\n"); diff --git a/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseEmailDomainDetails.java b/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseEmailDomainDetails.java index ee136fb..a062b4c 100755 --- a/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseEmailDomainDetails.java +++ b/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseEmailDomainDetails.java @@ -227,12 +227,10 @@ public int hashCode() { return Objects.hash(createdAt, updatedAt, expiresAt, registrar, nameservers, spfRecord, dmarcRecord, mxRecords); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class FilterAndRiskResponseEmailDomainDetails {\n"); - sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); sb.append(" expiresAt: ").append(toIndentedString(expiresAt)).append("\n"); diff --git a/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseEmailDomainDetailsMxRecords.java b/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseEmailDomainDetailsMxRecords.java index eb8f688..3dae4ef 100755 --- a/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseEmailDomainDetailsMxRecords.java +++ b/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseEmailDomainDetailsMxRecords.java @@ -62,12 +62,10 @@ public int hashCode() { return Objects.hash(nullMx); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class FilterAndRiskResponseEmailDomainDetailsMxRecords {\n"); - sb.append(" nullMx: ").append(toIndentedString(nullMx)).append("\n"); sb.append("}"); return sb.toString(); diff --git a/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseEmailDomainDetailsSpfRecord.java b/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseEmailDomainDetailsSpfRecord.java index 692b285..db52508 100755 --- a/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseEmailDomainDetailsSpfRecord.java +++ b/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseEmailDomainDetailsSpfRecord.java @@ -62,12 +62,10 @@ public int hashCode() { return Objects.hash(exists); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class FilterAndRiskResponseEmailDomainDetailsSpfRecord {\n"); - sb.append(" exists: ").append(toIndentedString(exists)).append("\n"); sb.append("}"); return sb.toString(); diff --git a/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseScoresAccountAbuse.java b/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseScoresAccountAbuse.java index e3a015f..4439bbc 100755 --- a/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseScoresAccountAbuse.java +++ b/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseScoresAccountAbuse.java @@ -55,12 +55,10 @@ public int hashCode() { return Objects.hash(score); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class FilterAndRiskResponseScoresAccountAbuse {\n"); - sb.append(" score: ").append(toIndentedString(score)).append("\n"); sb.append("}"); return sb.toString(); diff --git a/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseScoresAccountTakeover.java b/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseScoresAccountTakeover.java index 6065b8f..ca4c4c6 100755 --- a/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseScoresAccountTakeover.java +++ b/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseScoresAccountTakeover.java @@ -55,12 +55,10 @@ public int hashCode() { return Objects.hash(score); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class FilterAndRiskResponseScoresAccountTakeover {\n"); - sb.append(" score: ").append(toIndentedString(score)).append("\n"); sb.append("}"); return sb.toString(); diff --git a/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseScoresBot.java b/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseScoresBot.java index 8b8f678..921c508 100755 --- a/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseScoresBot.java +++ b/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseScoresBot.java @@ -55,12 +55,10 @@ public int hashCode() { return Objects.hash(score); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class FilterAndRiskResponseScoresBot {\n"); - sb.append(" score: ").append(toIndentedString(score)).append("\n"); sb.append("}"); return sb.toString(); diff --git a/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseSdks.java b/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseSdks.java index 6bd21e1..931846e 100755 --- a/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseSdks.java +++ b/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseSdks.java @@ -20,7 +20,7 @@ /** * Castle SDKs details */ -@ApiModel(value = "Castle SDKs details") +@ApiModel(description = "Castle SDKs details") @javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2025-01-20T18:58:06.855017776Z[GMT]") public class FilterAndRiskResponseSdks { @@ -85,12 +85,10 @@ public int hashCode() { return Objects.hash(client, server); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class FilterAndRiskResponseSdks {\n"); - sb.append(" client: ").append(toIndentedString(client)).append("\n"); sb.append(" server: ").append(toIndentedString(server)).append("\n"); sb.append("}"); diff --git a/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseSdksClient.java b/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseSdksClient.java index 44ac474..b3ff53a 100755 --- a/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseSdksClient.java +++ b/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseSdksClient.java @@ -84,12 +84,10 @@ public int hashCode() { return Objects.hash(name, version); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class FilterAndRiskResponseSdksClient {\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" version: ").append(toIndentedString(version)).append("\n"); sb.append("}"); diff --git a/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseSdksServer.java b/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseSdksServer.java index 7a076e8..51c4002 100755 --- a/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseSdksServer.java +++ b/src/main/java/io/castle/client/model/generated/FilterAndRiskResponseSdksServer.java @@ -84,12 +84,10 @@ public int hashCode() { return Objects.hash(name, version); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class FilterAndRiskResponseSdksServer {\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" version: ").append(toIndentedString(version)).append("\n"); sb.append("}"); diff --git a/src/main/java/io/castle/client/model/generated/FormulaRequest.java b/src/main/java/io/castle/client/model/generated/FormulaRequest.java new file mode 100755 index 0000000..3ec89c2 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/FormulaRequest.java @@ -0,0 +1,111 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * OpenAPI spec version: 1 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package io.castle.client.model.generated; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + +/** + * FormulaRequest + */ + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2025-01-20T18:58:06.855017776Z[GMT]") + +public class FormulaRequest { + @SerializedName("name") + private String name = null; + + @SerializedName("value") + private String value = null; + + public FormulaRequest name(String name) { + this.name = name; + return this; + } + + /** + * Formula name + * @return name + **/ + @ApiModelProperty(required = true, value = "Formula name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public FormulaRequest value(String value) { + this.value = value; + return this; + } + + /** + * Formula to calculate value + * @return value + **/ + @ApiModelProperty(required = true, value = "Formula to calculate value") + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FormulaRequest formulaRequest = (FormulaRequest) o; + return Objects.equals(this.name, formulaRequest.name) && + Objects.equals(this.value, formulaRequest.value); + } + + @Override + public int hashCode() { + return Objects.hash(name, value); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FormulaRequest {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/io/castle/client/model/generated/IP.java b/src/main/java/io/castle/client/model/generated/IP.java index 42dc2a3..2202660 100755 --- a/src/main/java/io/castle/client/model/generated/IP.java +++ b/src/main/java/io/castle/client/model/generated/IP.java @@ -172,7 +172,6 @@ public int hashCode() { return Objects.hash(asn, location, address, isp, type, privacy); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/io/castle/client/model/generated/IPIsp.java b/src/main/java/io/castle/client/model/generated/IPIsp.java index 7eccb15..6f84a6c 100755 --- a/src/main/java/io/castle/client/model/generated/IPIsp.java +++ b/src/main/java/io/castle/client/model/generated/IPIsp.java @@ -84,7 +84,6 @@ public int hashCode() { return Objects.hash(name, organization); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/io/castle/client/model/generated/IPLocation.java b/src/main/java/io/castle/client/model/generated/IPLocation.java index 4661691..69a3e0a 100755 --- a/src/main/java/io/castle/client/model/generated/IPLocation.java +++ b/src/main/java/io/castle/client/model/generated/IPLocation.java @@ -194,12 +194,10 @@ public int hashCode() { return Objects.hash(city, continentCode, countryCode, postalCode, regionCode, latitude, longitude); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class IPLocation {\n"); - sb.append(" city: ").append(toIndentedString(city)).append("\n"); sb.append(" continentCode: ").append(toIndentedString(continentCode)).append("\n"); sb.append(" countryCode: ").append(toIndentedString(countryCode)).append("\n"); diff --git a/src/main/java/io/castle/client/model/generated/IPPrivacy.java b/src/main/java/io/castle/client/model/generated/IPPrivacy.java index 91f7d78..676da96 100755 --- a/src/main/java/io/castle/client/model/generated/IPPrivacy.java +++ b/src/main/java/io/castle/client/model/generated/IPPrivacy.java @@ -133,7 +133,6 @@ public int hashCode() { public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class IPPrivacy {\n"); - sb.append(" anonymous: ").append(toIndentedString(anonymous)).append("\n"); sb.append(" datacenter: ").append(toIndentedString(datacenter)).append("\n"); sb.append(" proxy: ").append(toIndentedString(proxy)).append("\n"); diff --git a/src/main/java/io/castle/client/model/generated/ListColor.java b/src/main/java/io/castle/client/model/generated/ListColor.java new file mode 100755 index 0000000..2325364 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/ListColor.java @@ -0,0 +1,81 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * OpenAPI spec version: 1 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package io.castle.client.model.generated; + +import io.swagger.annotations.ApiModelProperty; +import com.google.gson.annotations.SerializedName; +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Color assigned to the List. These colors can be used to represent different sentiments, such as red for blocked records or green for trusted. + */ +@JsonAdapter(ListColor.Adapter.class) +public enum ListColor { + @SerializedName("$red") + RED("$red"), + @SerializedName("$orange") + ORANGE("$orange"), + @SerializedName("$yellow") + YELLOW("$yellow"), + @SerializedName("$green") + GREEN("$green"), + @SerializedName("$blue") + BLUE("$blue"), + @SerializedName("$purple") + PURPLE("$purple"), + @SerializedName("$gray") + GRAY("$gray"), + @SerializedName("$black") + BLACK("$black"); + + private String value; + + ListColor(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ListColor fromValue(String input) { + for (ListColor b : ListColor.values()) { + if (b.value.equals(input)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ListColor enumeration) throws IOException { + jsonWriter.value(String.valueOf(enumeration.getValue())); + } + + @Override + public ListColor read(final JsonReader jsonReader) throws IOException { + Object value = jsonReader.nextString(); + return ListColor.fromValue((String)(value)); + } + } +} diff --git a/src/main/java/io/castle/client/model/generated/ListItem.java b/src/main/java/io/castle/client/model/generated/ListItem.java new file mode 100755 index 0000000..60529c3 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/ListItem.java @@ -0,0 +1,157 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * OpenAPI spec version: 1 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package io.castle.client.model.generated; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import org.threeten.bp.OffsetDateTime; + +import java.util.Objects; +/** + * ListItem + */ + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2025-01-20T18:58:06.855017776Z[GMT]") + +public class ListItem extends BaseItem { + @SerializedName("id") + private String id = null; + + @SerializedName("list_id") + private String listId = null; + + @SerializedName("archived") + private Boolean archived = null; + + @SerializedName("created_at") + private OffsetDateTime createdAt = null; + + public ListItem id(String id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @ApiModelProperty(example = "2ee938c8-24c2-4c26-9d25-19511dd75029", required = true, value = "") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public ListItem listId(String listId) { + this.listId = listId; + return this; + } + + /** + * ID of the List to which this List Item belongs to + * @return listId + **/ + @ApiModelProperty(example = "2ee938c8-24c2-4c26-9d25-19511dd75029", required = true, value = "ID of the List to which this List Item belongs to") + public String getListId() { + return listId; + } + + public void setListId(String listId) { + this.listId = listId; + } + + public ListItem archived(Boolean archived) { + this.archived = archived; + return this; + } + + /** + * Get archived + * @return archived + **/ + @ApiModelProperty(value = "") + public Boolean isArchived() { + return archived; + } + + public void setArchived(Boolean archived) { + this.archived = archived; + } + + public ListItem createdAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * Get createdAt + * @return createdAt + **/ + @ApiModelProperty(example = "2021-09-27T16:46:38.313Z", value = "") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListItem listItem = (ListItem) o; + return Objects.equals(this.id, listItem.id) && + Objects.equals(this.listId, listItem.listId) && + Objects.equals(this.archived, listItem.archived) && + Objects.equals(this.createdAt, listItem.createdAt) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(id, listId, archived, createdAt, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListItem {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" listId: ").append(toIndentedString(listId)).append("\n"); + sb.append(" archived: ").append(toIndentedString(archived)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/io/castle/client/model/generated/ListItemAuthor.java b/src/main/java/io/castle/client/model/generated/ListItemAuthor.java new file mode 100755 index 0000000..bbf10ca --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/ListItemAuthor.java @@ -0,0 +1,109 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * OpenAPI spec version: 1 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package io.castle.client.model.generated; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + +/** + * Indicates who or how the list item was created. Typically, this refers to the user that created the item from within the Castle Dashboard, or the policy ID if it was automatically created via automation. + */ +@ApiModel(description = "Indicates who or how the list item was created. Typically, this refers to the user that created the item from within the Castle Dashboard, or the policy ID if it was automatically created via automation.") +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2025-01-20T18:58:06.855017776Z[GMT]") + +public class ListItemAuthor { + @SerializedName("type") + private AuthorType type = null; + + @SerializedName("identifier") + private String identifier = null; + + public ListItemAuthor type(AuthorType type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @ApiModelProperty(required = true, value = "") + public AuthorType getType() { + return type; + } + + public void setType(AuthorType type) { + this.type = type; + } + + public ListItemAuthor identifier(String identifier) { + this.identifier = identifier; + return this; + } + + /** + * Get identifier + * @return identifier + **/ + @ApiModelProperty(required = true, value = "") + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListItemAuthor listItemAuthor = (ListItemAuthor) o; + return Objects.equals(this.type, listItemAuthor.type) && + Objects.equals(this.identifier, listItemAuthor.identifier); + } + + @Override + public int hashCode() { + return Objects.hash(type, identifier); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListItemAuthor {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" identifier: ").append(toIndentedString(identifier)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/io/castle/client/model/generated/ListItemListCount.java b/src/main/java/io/castle/client/model/generated/ListItemListCount.java new file mode 100755 index 0000000..16670c2 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/ListItemListCount.java @@ -0,0 +1,87 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * OpenAPI spec version: 1 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package io.castle.client.model.generated; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + +/** + * ListItemListCount + */ + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2025-01-20T18:58:06.855017776Z[GMT]") + +public class ListItemListCount { + @SerializedName("total_count") + private int totalCount; + + public ListItemListCount totalCount(int totalCount) { + this.totalCount = totalCount; + return this; + } + + /** + * A number of list items matching the query capped at 100,000. + * minimum: 0 + * @return totalCount + **/ + @ApiModelProperty(example = "1", required = true, value = "A number of list items matching the query capped at 100,000.") + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListItemListCount listItemListCount = (ListItemListCount) o; + return Objects.equals(this.totalCount, listItemListCount.totalCount); + } + + @Override + public int hashCode() { + return Objects.hash(totalCount); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListItemListCount {\n"); + sb.append(" totalCount: ").append(toIndentedString(totalCount)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/io/castle/client/model/generated/ListItemQuery.java b/src/main/java/io/castle/client/model/generated/ListItemQuery.java new file mode 100755 index 0000000..3a23b8b --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/ListItemQuery.java @@ -0,0 +1,169 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * OpenAPI spec version: 1 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package io.castle.client.model.generated; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * ListItemQuery + */ + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2025-01-20T18:58:06.855017776Z[GMT]") + +public class ListItemQuery { + @SerializedName("page") + private Integer page = 1; + + @SerializedName("results_size") + private Integer resultsSize = 20; + + @SerializedName("sort") + private ListItemQuerySort sort = null; + + @SerializedName("filters") + private List filters = null; + + public ListItemQuery sort(ListItemQuerySort sort) { + this.sort = sort; + return this; + } + + /** + * Get sort + * @return sort + **/ + @ApiModelProperty(value = "") + public ListItemQuerySort getSort() { + return sort; + } + + public void setSort(ListItemQuerySort sort) { + this.sort = sort; + } + + public ListItemQuery filters(List filters) { + this.filters = filters; + return this; + } + + public ListItemQuery addFiltersItem(BaseListItemQueryFilter filtersItem) { + if (this.filters == null) { + this.filters = new ArrayList(); + } + this.filters.add(filtersItem); + return this; + } + + /** + * Get filters + * @return filters + **/ + @ApiModelProperty(value = "") + public List getFilters() { + return filters; + } + + public void setFilters(List filters) { + this.filters = filters; + } + + public ListItemQuery page(Integer page) { + this.page = page; + return this; + } + + /** + * Page number + * minimum: 1 + * maximum: 1000 + * @return page + **/ + @ApiModelProperty(example = "1", value = "Page number") + public Integer getPage() { + return page; + } + + public void setPage(Integer page) { + this.page = page; + } + + public ListItemQuery resultsSize(Integer resultsSize) { + this.resultsSize = resultsSize; + return this; + } + + /** + * How many records to show per page + * minimum: 1 + * maximum: 100 + * @return resultsSize + **/ + @ApiModelProperty(example = "50", value = "How many records to show per page") + public Integer getResultsSize() { + return resultsSize; + } + + public void setResultsSize(Integer resultsSize) { + this.resultsSize = resultsSize; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListItemQuery listItemQuery = (ListItemQuery) o; + return Objects.equals(this.page, listItemQuery.page) && + Objects.equals(this.resultsSize, listItemQuery.resultsSize) && + Objects.equals(this.sort, listItemQuery.sort) && + Objects.equals(this.filters, listItemQuery.filters); + } + + @Override + public int hashCode() { + return Objects.hash(page, resultsSize, sort, filters); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListItemQuery {\n"); + sb.append(" sort: ").append(toIndentedString(sort)).append("\n"); + sb.append(" filters: ").append(toIndentedString(filters)).append("\n"); + sb.append(" page: ").append(toIndentedString(page)).append("\n"); + sb.append(" resultsSize: ").append(toIndentedString(resultsSize)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/io/castle/client/model/generated/ListItemQueryFilter.java b/src/main/java/io/castle/client/model/generated/ListItemQueryFilter.java new file mode 100755 index 0000000..8cf4f4b --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/ListItemQueryFilter.java @@ -0,0 +1,230 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * OpenAPI spec version: 1 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package io.castle.client.model.generated; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModelProperty; + +import java.io.IOException; +import java.util.Objects; +/** + * ListItemQueryFilter + */ + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2025-01-20T18:58:06.855017776Z[GMT]") + +public class ListItemQueryFilter extends BaseListItemQueryFilter { + /** + * List Item field name + */ + @JsonAdapter(FieldEnum.Adapter.class) + public enum FieldEnum { + @SerializedName("primary_value") + PRIMARY_VALUE("primary_value"), + @SerializedName("secondary_value") + SECONDARY_VALUE("secondary_value"), + @SerializedName("archived") + ARCHIVED("archived"); + + private String value; + + FieldEnum(String value) { + this.value = value; + } + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static FieldEnum fromValue(String input) { + for (FieldEnum b : FieldEnum.values()) { + if (b.value.equals(input)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final FieldEnum enumeration) throws IOException { + jsonWriter.value(String.valueOf(enumeration.getValue())); + } + + @Override + public FieldEnum read(final JsonReader jsonReader) throws IOException { + Object value = jsonReader.nextString(); + return FieldEnum.fromValue((String)(value)); + } + } + } @SerializedName("field") + private FieldEnum field = null; + + /** + * Gets or Sets op + */ + @JsonAdapter(OpEnum.Adapter.class) + public enum OpEnum { + @SerializedName("$eq") + _EQ("$eq"); + + private String value; + + OpEnum(String value) { + this.value = value; + } + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static OpEnum fromValue(String input) { + for (OpEnum b : OpEnum.values()) { + if (b.value.equals(input)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final OpEnum enumeration) throws IOException { + jsonWriter.value(String.valueOf(enumeration.getValue())); + } + + @Override + public OpEnum read(final JsonReader jsonReader) throws IOException { + Object value = jsonReader.nextString(); + return OpEnum.fromValue((String)(value)); + } + } + } + + @SerializedName("op") + private OpEnum op = null; + + @SerializedName("value") + private Object value = null; + + public ListItemQueryFilter field(FieldEnum field) { + this.field = field; + return this; + } + + /** + * List Item field name + * @return field + **/ + @ApiModelProperty(example = "primary_value", required = true, value = "List Item field name") + public FieldEnum getField() { + return field; + } + + public void setField(FieldEnum field) { + this.field = field; + } + + public ListItemQueryFilter op(OpEnum op) { + this.op = op; + return this; + } + + /** + * Get op + * @return op + **/ + @ApiModelProperty(example = "$eq", required = true, value = "") + public OpEnum getOp() { + return op; + } + + public void setOp(OpEnum op) { + this.op = op; + } + + public ListItemQueryFilter value(Object value) { + this.value = value; + return this; + } + + /** + * Can be string or bool + * @return value + **/ + @ApiModelProperty(example = "effb8e3c-084c-4d3e-b7ee-f8741b79c8d2", required = true, value = "Can be string or bool") + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListItemQueryFilter listItemQueryFilter = (ListItemQueryFilter) o; + return Objects.equals(this.field, listItemQueryFilter.field) && + Objects.equals(this.op, listItemQueryFilter.op) && + Objects.equals(this.value, listItemQueryFilter.value); + } + + @Override + public int hashCode() { + return Objects.hash(field, op, value); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListItemQueryFilter {\n"); + + sb.append(" field: ").append(toIndentedString(field)).append("\n"); + sb.append(" op: ").append(toIndentedString(op)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/io/castle/client/model/generated/ListItemQueryOrFilter.java b/src/main/java/io/castle/client/model/generated/ListItemQueryOrFilter.java new file mode 100755 index 0000000..380bcb0 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/ListItemQueryOrFilter.java @@ -0,0 +1,167 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * OpenAPI spec version: 1 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package io.castle.client.model.generated; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModelProperty; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +/** + * ListItemOrQueryFilter + */ + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2025-01-20T18:58:06.855017776Z[GMT]") + +public class ListItemQueryOrFilter extends BaseListItemQueryFilter { + /** + * Gets or Sets op + */ + @JsonAdapter(OpEnum.Adapter.class) + public enum OpEnum { + @SerializedName("$or") + _OR("$or"); + + private String value; + + OpEnum(String value) { + this.value = value; + } + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static OpEnum fromValue(String input) { + for (OpEnum b : OpEnum.values()) { + if (b.value.equals(input)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final OpEnum enumeration) throws IOException { + jsonWriter.value(String.valueOf(enumeration.getValue())); + } + + @Override + public OpEnum read(final JsonReader jsonReader) throws IOException { + Object value = jsonReader.nextString(); + return OpEnum.fromValue((String)(value)); + } + } + } + + @SerializedName("op") + private OpEnum op = null; + + @SerializedName("value") + private List value = new ArrayList(); + + public ListItemQueryOrFilter op(OpEnum op) { + this.op = op; + return this; + } + + /** + * Get op + * @return op + **/ + @ApiModelProperty(example = "$or", required = true, value = "") + public OpEnum getOp() { + return op; + } + + public void setOp(OpEnum op) { + this.op = op; + } + + public ListItemQueryOrFilter value(List value) { + this.value = value; + return this; + } + + public ListItemQueryOrFilter addValueItem(ListItemQueryFilter valueItem) { + this.value.add(valueItem); + return this; + } + + /** + * Get value + * @return value + **/ + @ApiModelProperty(required = true, value = "") + public List getValue() { + return value; + } + + public void setValue(List value) { + this.value = value; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListItemQueryOrFilter listItemQueryOrFilter = (ListItemQueryOrFilter) o; + return Objects.equals(this.op, listItemQueryOrFilter.op) && + Objects.equals(this.value, listItemQueryOrFilter.value); + } + + @Override + public int hashCode() { + return Objects.hash(op, value); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListItemOrQueryFilter {\n"); + + sb.append(" op: ").append(toIndentedString(op)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/io/castle/client/model/generated/ListItemQuerySort.java b/src/main/java/io/castle/client/model/generated/ListItemQuerySort.java new file mode 100755 index 0000000..90bbaba --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/ListItemQuerySort.java @@ -0,0 +1,202 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * OpenAPI spec version: 1 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package io.castle.client.model.generated; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.IOException; +import java.util.Objects; +/** + * List Item sort order, based on creation timestamp + */ +@ApiModel(description = "List Item sort order, based on creation timestamp") +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2025-01-20T18:58:06.855017776Z[GMT]") + +public class ListItemQuerySort { + /** + * created_at is the only allowed field for sorting List Items + */ + @JsonAdapter(FieldEnum.Adapter.class) + public enum FieldEnum { + @SerializedName("created_at") + CREATED_AT("created_at"); + + private String value; + + FieldEnum(String value) { + this.value = value; + } + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static FieldEnum fromValue(String input) { + for (FieldEnum b : FieldEnum.values()) { + if (b.value.equals(input)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final FieldEnum enumeration) throws IOException { + jsonWriter.value(String.valueOf(enumeration.getValue())); + } + + @Override + public FieldEnum read(final JsonReader jsonReader) throws IOException { + Object value = jsonReader.nextString(); + return FieldEnum.fromValue((String)(value)); + } + } + } @SerializedName("field") + private FieldEnum field = null; + + /** + * Gets or Sets order + */ + @JsonAdapter(OrderEnum.Adapter.class) + public enum OrderEnum { + @SerializedName("asc") + ASC("asc"), + @SerializedName("desc") + DESC("desc"); + + private String value; + + OrderEnum(String value) { + this.value = value; + } + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static OrderEnum fromValue(String input) { + for (OrderEnum b : OrderEnum.values()) { + if (b.value.equals(input)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final OrderEnum enumeration) throws IOException { + jsonWriter.value(String.valueOf(enumeration.getValue())); + } + + @Override + public OrderEnum read(final JsonReader jsonReader) throws IOException { + Object value = jsonReader.nextString(); + return OrderEnum.fromValue((String)(value)); + } + } + } @SerializedName("order") + private OrderEnum order = null; + + public ListItemQuerySort field(FieldEnum field) { + this.field = field; + return this; + } + + /** + * created_at is the only allowed field for sorting List Items + * @return field + **/ + @ApiModelProperty(example = "created_at", required = true, value = "created_at is the only allowed field for sorting List Items") + public FieldEnum getField() { + return field; + } + + public void setField(FieldEnum field) { + this.field = field; + } + + public ListItemQuerySort order(OrderEnum order) { + this.order = order; + return this; + } + + /** + * Get order + * @return order + **/ + @ApiModelProperty(example = "asc", required = true, value = "") + public OrderEnum getOrder() { + return order; + } + + public void setOrder(OrderEnum order) { + this.order = order; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListItemQuerySort listItemQuerySort = (ListItemQuerySort) o; + return Objects.equals(this.field, listItemQuerySort.field) && + Objects.equals(this.order, listItemQuerySort.order); + } + + @Override + public int hashCode() { + return Objects.hash(field, order); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListItemQuerySort {\n"); + sb.append(" field: ").append(toIndentedString(field)).append("\n"); + sb.append(" order: ").append(toIndentedString(order)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/io/castle/client/model/generated/ListItemRequest.java b/src/main/java/io/castle/client/model/generated/ListItemRequest.java new file mode 100755 index 0000000..577bd39 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/ListItemRequest.java @@ -0,0 +1,144 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * OpenAPI spec version: 1 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package io.castle.client.model.generated; + +import java.util.Objects; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * ListItemRequest + */ + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2025-01-20T18:58:06.855017776Z[GMT]") + +public class ListItemRequest extends BaseItem { + /** + * Describes a strategy to use when a List Item with the same `(primary, secondary)` values is already in the List. Available strategies: - `$error` - return a 422 HTTP error - `$replace` - archive the existing List Item and create a new one - `$update` - if the author matches the existing List Item, update it. Otherwise, throw an HTTP 422 error. - `$update_or_replace` - if the author matches the existing List Item, update it. Otherwise, archive the existing List Item and create a new one. + */ + @JsonAdapter(ModeEnum.Adapter.class) + public enum ModeEnum { + @SerializedName("$error") + ERROR("$error"), + @SerializedName("$replace") + REPLACE("$replace"), + @SerializedName("$update") + UPDATE("$update"), + @SerializedName("$update_or_replace") + UPDATE_OR_REPLACE("$update_or_replace"); + + private String value; + + ModeEnum(String value) { + this.value = value; + } + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ModeEnum fromValue(String input) { + for (ModeEnum b : ModeEnum.values()) { + if (b.value.equals(input)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ModeEnum enumeration) throws IOException { + jsonWriter.value(String.valueOf(enumeration.getValue())); + } + + @Override + public ModeEnum read(final JsonReader jsonReader) throws IOException { + Object value = jsonReader.nextString(); + return ModeEnum.fromValue((String)(value)); + } + } + } + @SerializedName("mode") + private ModeEnum mode = ModeEnum.ERROR; + + public ListItemRequest mode(ModeEnum mode) { + this.mode = mode; + return this; + } + + /** + * Describes a strategy to use when a List Item with the same `(primary, secondary)` values is already in the List. Available strategies: - `$error` - return a 422 HTTP error - `$replace` - archive the existing List Item and create a new one - `$update` - if the author matches the existing List Item, update it. Otherwise, throw an HTTP 422 error. - `$update_or_replace` - if the author matches the existing List Item, update it. Otherwise, archive the existing List Item and create a new one. + * @return mode + **/ + @ApiModelProperty(value = "Describes a strategy to use when a List Item with the same `(primary, secondary)` values is already in the List. Available strategies: - `$error` - return a 422 HTTP error - `$replace` - archive the existing List Item and create a new one - `$update` - if the author matches the existing List Item, update it. Otherwise, throw an HTTP 422 error. - `$update_or_replace` - if the author matches the existing List Item, update it. Otherwise, archive the existing List Item and create a new one. ") + public ModeEnum getMode() { + return mode; + } + + public void setMode(ModeEnum mode) { + this.mode = mode; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListItemRequest listItemRequest = (ListItemRequest) o; + return Objects.equals(this.mode, listItemRequest.mode) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(mode, super.hashCode()); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListItemRequest {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" mode: ").append(toIndentedString(mode)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/io/castle/client/model/generated/ListItemsBatchRequest.java b/src/main/java/io/castle/client/model/generated/ListItemsBatchRequest.java new file mode 100755 index 0000000..cb26174 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/ListItemsBatchRequest.java @@ -0,0 +1,97 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * OpenAPI spec version: 1 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package io.castle.client.model.generated; + +import java.util.Objects; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +/** + * ListItemsBatchRequest + */ + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2025-01-20T18:58:06.855017776Z[GMT]") + +public class ListItemsBatchRequest { + @SerializedName("items") + private List items = null; + + public ListItemsBatchRequest items(List items) { + this.items = items; + return this; + } + + public ListItemsBatchRequest addItemsItem(ListItemRequest itemsItem) { + if (this.items == null) { + this.items = new ArrayList(); + } + this.items.add(itemsItem); + return this; + } + + /** + * Get items + * @return items + **/ + @ApiModelProperty(value = "") + public List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListItemsBatchRequest listItemsBatchRequest = (ListItemsBatchRequest) o; + return Objects.equals(this.items, listItemsBatchRequest.items); + } + + @Override + public int hashCode() { + return Objects.hash(items); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListItemsBatchRequest {\n"); + sb.append(" items: ").append(toIndentedString(items)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/io/castle/client/model/generated/ListItemsBatchResponse.java b/src/main/java/io/castle/client/model/generated/ListItemsBatchResponse.java new file mode 100755 index 0000000..c1b3d1a --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/ListItemsBatchResponse.java @@ -0,0 +1,202 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * OpenAPI spec version: 1 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package io.castle.client.model.generated; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + +/** + * ListItemsBatchResponse + */ + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2025-01-20T18:58:06.855017776Z[GMT]") + +public class ListItemsBatchResponse { + @SerializedName("total_received") + private Integer totalReceived = null; + + @SerializedName("total_processed") + private Integer totalProcessed = null; + + @SerializedName("created") + private Integer created = null; + + @SerializedName("updated") + private Integer updated = null; + + @SerializedName("replaced") + private Integer replaced = null; + + @SerializedName("errored") + private Integer errored = null; + + public ListItemsBatchResponse totalReceived(Integer totalReceived) { + this.totalReceived = totalReceived; + return this; + } + + /** + * Total number of items received + * @return totalReceived + **/ + @ApiModelProperty(required = true, value = "Total number of items received") + public int getTotalReceived() { + return totalReceived; + } + + public void setTotalReceived(int totalReceived) { + this.totalReceived = totalReceived; + } + + public ListItemsBatchResponse totalProcessed(int totalProcessed) { + this.totalProcessed = totalProcessed; + return this; + } + + /** + * Total number of items processed without any errors + * @return totalProcessed + **/ + @ApiModelProperty(required = true, value = "Total number of items processed without any errors") + public int getTotalProcessed() { + return totalProcessed; + } + + public void setTotalProcessed(int totalProcessed) { + this.totalProcessed = totalProcessed; + } + + public ListItemsBatchResponse created(int created) { + this.created = created; + return this; + } + + /** + * Number of items created + * @return created + **/ + @ApiModelProperty(value = "Number of items created") + public int getCreated() { + return created; + } + + public void setCreated(int created) { + this.created = created; + } + + public ListItemsBatchResponse updated(int updated) { + this.updated = updated; + return this; + } + + /** + * Number of items updated + * @return updated + **/ + @ApiModelProperty(value = "Number of items updated") + public int getUpdated() { + return updated; + } + + public void setUpdated(int updated) { + this.updated = updated; + } + + public ListItemsBatchResponse replaced(int replaced) { + this.replaced = replaced; + return this; + } + + /** + * Total number of items replaced + * @return replaced + **/ + @ApiModelProperty(value = "Total number of items replaced") + public int getReplaced() { + return replaced; + } + + public void setReplaced(int replaced) { + this.replaced = replaced; + } + + public ListItemsBatchResponse errored(int errored) { + this.errored = errored; + return this; + } + + /** + * Total number of items that errored + * @return errored + **/ + @ApiModelProperty(value = "Total number of items that errored") + public int getErrored() { + return errored; + } + + public void setErrored(int errored) { + this.errored = errored; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListItemsBatchResponse listItemsBatchResponse = (ListItemsBatchResponse) o; + return Objects.equals(this.totalReceived, listItemsBatchResponse.totalReceived) && + Objects.equals(this.totalProcessed, listItemsBatchResponse.totalProcessed) && + Objects.equals(this.created, listItemsBatchResponse.created) && + Objects.equals(this.updated, listItemsBatchResponse.updated) && + Objects.equals(this.replaced, listItemsBatchResponse.replaced) && + Objects.equals(this.errored, listItemsBatchResponse.errored); + } + + @Override + public int hashCode() { + return Objects.hash(totalReceived, totalProcessed, created, updated, replaced, errored); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListItemsBatchResponse {\n"); + sb.append(" totalReceived: ").append(toIndentedString(totalReceived)).append("\n"); + sb.append(" totalProcessed: ").append(toIndentedString(totalProcessed)).append("\n"); + sb.append(" created: ").append(toIndentedString(created)).append("\n"); + sb.append(" updated: ").append(toIndentedString(updated)).append("\n"); + sb.append(" replaced: ").append(toIndentedString(replaced)).append("\n"); + sb.append(" errored: ").append(toIndentedString(errored)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/io/castle/client/model/generated/ListQuery.java b/src/main/java/io/castle/client/model/generated/ListQuery.java new file mode 100755 index 0000000..d420423 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/ListQuery.java @@ -0,0 +1,193 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * OpenAPI spec version: 1 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package io.castle.client.model.generated; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +/** + * List Query + */ +@ApiModel(description = "List Query") +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2025-01-20T18:58:06.855017776Z[GMT]") + +public class ListQuery { + @SerializedName("filters") + private List filters = null; + + @SerializedName("page") + private Integer page = null; + + @SerializedName("results_size") + private Integer resultsSize = null; + + @SerializedName("include_size_label") + private Boolean includeSizeLabel = null; + + @SerializedName("sort") + private ListQuerySort sort = null; + + public ListQuery filters(List filters) { + this.filters = filters; + return this; + } + + public ListQuery addFiltersItem(ListQueryFilter filtersItem) { + if (this.filters == null) { + this.filters = new ArrayList(); + } + this.filters.add(filtersItem); + return this; + } + + /** + * Additional filters to query lists by fields and archival status + * @return filters + **/ + @ApiModelProperty(example = "[{\"field\":\"primary_field\",\"op\":\"$eq\",\"value\":\"device.fingerprint\"},{\"field\":\"archived\",\"op\":\"$eq\",\"value\":false},{\"op\":\"$or\",\"value\":[{\"field\":\"secondary_field\",\"op\":\"$eq\",\"value\":\"user.id\"}]},{\"op\":\"$or\",\"value\":[{\"field\":\"secondary_field\",\"op\":\"$eq\",\"value\":\"user.email\"}]}]", value = "Additional filters to query lists by fields and archival status") + public List getFilters() { + return filters; + } + + public void setFilters(List filters) { + this.filters = filters; + } + + public ListQuery page(Integer page) { + this.page = page; + return this; + } + + /** + * Page number + * minimum: 1 + * maximum: 1000 + * @return page + **/ + @ApiModelProperty(example = "2", value = "Page number") + public Integer getPage() { + return page; + } + + public void setPage(Integer page) { + this.page = page; + } + + public ListQuery resultsSize(Integer resultsSize) { + this.resultsSize = resultsSize; + return this; + } + + /** + * How many records to show per page + * minimum: 1 + * maximum: 100 + * @return resultsSize + **/ + @ApiModelProperty(example = "50", value = "How many records to show per page") + public Integer getResultsSize() { + return resultsSize; + } + + public void setResultsSize(Integer resultsSize) { + this.resultsSize = resultsSize; + } + + public ListQuery includeSizeLabel(Boolean includeSizeLabel) { + this.includeSizeLabel = includeSizeLabel; + return this; + } + + /** + * Whether to include the size label in the response + * @return includeSizeLabel + **/ + @ApiModelProperty(example = "true", value = "Whether to include the size label in the response") + public Boolean isIncludeSizeLabel() { + return includeSizeLabel; + } + + public void setIncludeSizeLabel(Boolean includeSizeLabel) { + this.includeSizeLabel = includeSizeLabel; + } + + public ListQuery sort(ListQuerySort sort) { + this.sort = sort; + return this; + } + + /** + * Get sort + * @return sort + **/ + @ApiModelProperty(value = "") + public ListQuerySort getSort() { + return sort; + } + + public void setSort(ListQuerySort sort) { + this.sort = sort; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListQuery listQuery = (ListQuery) o; + return Objects.equals(this.filters, listQuery.filters) && + Objects.equals(this.page, listQuery.page) && + Objects.equals(this.resultsSize, listQuery.resultsSize) && + Objects.equals(this.includeSizeLabel, listQuery.includeSizeLabel) && + Objects.equals(this.sort, listQuery.sort); + } + + @Override + public int hashCode() { + return Objects.hash(filters, page, resultsSize, includeSizeLabel, sort); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListQuery {\n"); + sb.append(" filters: ").append(toIndentedString(filters)).append("\n"); + sb.append(" page: ").append(toIndentedString(page)).append("\n"); + sb.append(" resultsSize: ").append(toIndentedString(resultsSize)).append("\n"); + sb.append(" includeSizeLabel: ").append(toIndentedString(includeSizeLabel)).append("\n"); + sb.append(" sort: ").append(toIndentedString(sort)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/io/castle/client/model/generated/ListQueryFilter.java b/src/main/java/io/castle/client/model/generated/ListQueryFilter.java new file mode 100755 index 0000000..a4120df --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/ListQueryFilter.java @@ -0,0 +1,230 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * OpenAPI spec version: 1 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package io.castle.client.model.generated; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModelProperty; + +import java.io.IOException; +import java.util.Objects; +/** + * ListQueryFilter + */ + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2025-01-20T18:58:06.855017776Z[GMT]") + +public class ListQueryFilter extends BaseListQueryFilter{ + /** + * List field name + */ + @JsonAdapter(FieldEnum.Adapter.class) + public enum FieldEnum { + @SerializedName("primary_field") + PRIMARY_FIELD("primary_field"), + @SerializedName("secondary_field") + SECONDARY_FIELD("secondary_field"), + @SerializedName("archived") + ARCHIVED("archived"); + + private String value; + + FieldEnum(String value) { + this.value = value; + } + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static FieldEnum fromValue(String input) { + for (FieldEnum b : FieldEnum.values()) { + if (b.value.equals(input)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final FieldEnum enumeration) throws IOException { + jsonWriter.value(String.valueOf(enumeration.getValue())); + } + + @Override + public FieldEnum read(final JsonReader jsonReader) throws IOException { + Object value = jsonReader.nextString(); + return FieldEnum.fromValue((String)(value)); + } + } + } @SerializedName("field") + private FieldEnum field = null; + + /** + * Gets or Sets op + */ + @JsonAdapter(OpEnum.Adapter.class) + public enum OpEnum { + @SerializedName("$eq") + _EQ("$eq"); + + private String value; + + OpEnum(String value) { + this.value = value; + } + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static OpEnum fromValue(String input) { + for (OpEnum b : OpEnum.values()) { + if (b.value.equals(input)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final OpEnum enumeration) throws IOException { + jsonWriter.value(String.valueOf(enumeration.getValue())); + } + + @Override + public OpEnum read(final JsonReader jsonReader) throws IOException { + Object value = jsonReader.nextString(); + return OpEnum.fromValue((String)(value)); + } + } + } + + @SerializedName("op") + private OpEnum op = null; + + @SerializedName("value") + private Object value = null; + + public ListQueryFilter field(FieldEnum field) { + this.field = field; + return this; + } + + /** + * List field name + * @return field + **/ + @ApiModelProperty(example = "primary_field", required = true, value = "List field name") + public FieldEnum getField() { + return field; + } + + public void setField(FieldEnum field) { + this.field = field; + } + + public ListQueryFilter op(OpEnum op) { + this.op = op; + return this; + } + + /** + * Get op + * @return op + **/ + @ApiModelProperty(example = "$eq", required = true, value = "") + public OpEnum getOp() { + return op; + } + + public void setOp(OpEnum op) { + this.op = op; + } + + public ListQueryFilter value(Object value) { + this.value = value; + return this; + } + + /** + * Can be string or bool + * @return value + **/ + @ApiModelProperty(example = "effb8e3c-084c-4d3e-b7ee-f8741b79c8d2", required = true, value = "Can be string or bool") + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListQueryFilter listQueryFilter = (ListQueryFilter) o; + return Objects.equals(this.field, listQueryFilter.field) && + Objects.equals(this.op, listQueryFilter.op) && + Objects.equals(this.value, listQueryFilter.value); + } + + @Override + public int hashCode() { + return Objects.hash(field, op, value); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListQueryFilter {\n"); + + sb.append(" field: ").append(toIndentedString(field)).append("\n"); + sb.append(" op: ").append(toIndentedString(op)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/io/castle/client/model/generated/ListQueryOrFilter.java b/src/main/java/io/castle/client/model/generated/ListQueryOrFilter.java new file mode 100755 index 0000000..82b5ab1 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/ListQueryOrFilter.java @@ -0,0 +1,165 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * OpenAPI spec version: 1 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package io.castle.client.model.generated; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModelProperty; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +/** + * ListOrQueryFilter + */ + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2025-01-20T18:58:06.855017776Z[GMT]") + +public class ListQueryOrFilter extends BaseListQueryFilter { + /** + * Gets or Sets op + */ + @JsonAdapter(OpEnum.Adapter.class) + public enum OpEnum { + @SerializedName("$or") + _OR("$or"); + + private String value; + + OpEnum(String value) { + this.value = value; + } + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static OpEnum fromValue(String input) { + for (OpEnum b : OpEnum.values()) { + if (b.value.equals(input)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final OpEnum enumeration) throws IOException { + jsonWriter.value(String.valueOf(enumeration.getValue())); + } + + @Override + public OpEnum read(final JsonReader jsonReader) throws IOException { + Object value = jsonReader.nextString(); + return OpEnum.fromValue((String)(value)); + } + } + } + + @SerializedName("op") + private OpEnum op = null; + + @SerializedName("value") + private List value = new ArrayList(); + + public ListQueryOrFilter op(OpEnum op) { + this.op = op; + return this; + } + + /** + * Get op + * @return op + **/ + @ApiModelProperty(example = "$or", required = true, value = "") + public OpEnum getOp() { + return op; + } + + public void setOp(OpEnum op) { + this.op = op; + } + + public ListQueryOrFilter value(List value) { + this.value = value; + return this; + } + + public ListQueryOrFilter addValueItem(ListQueryFilter valueItem) { + this.value.add(valueItem); + return this; + } + + /** + * Get value + * @return value + **/ + @ApiModelProperty(required = true, value = "") + public List getValue() { + return value; + } + + public void setValue(List value) { + this.value = value; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListQueryOrFilter listOrQueryFilter = (ListQueryOrFilter) o; + return Objects.equals(this.op, listOrQueryFilter.op) && + Objects.equals(this.value, listOrQueryFilter.value); + } + + @Override + public int hashCode() { + return Objects.hash(op, value); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListOrQueryFilter {\n"); + + sb.append(" op: ").append(toIndentedString(op)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/io/castle/client/model/generated/ListQueryResponse.java b/src/main/java/io/castle/client/model/generated/ListQueryResponse.java new file mode 100755 index 0000000..f6233e3 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/ListQueryResponse.java @@ -0,0 +1,64 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * OpenAPI spec version: 1 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package io.castle.client.model.generated; + +import io.swagger.annotations.ApiModel; + +import java.util.ArrayList; +import java.util.Objects; + +/** + * List Query Response + */ +@ApiModel(description = "List Query Response") +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2025-01-20T18:58:06.855017776Z[GMT]") + +public class ListQueryResponse extends ArrayList { + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListQueryResponse {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/io/castle/client/model/generated/ListQuerySort.java b/src/main/java/io/castle/client/model/generated/ListQuerySort.java new file mode 100755 index 0000000..2bf0b53 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/ListQuerySort.java @@ -0,0 +1,204 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * OpenAPI spec version: 1 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package io.castle.client.model.generated; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.IOException; +import java.util.Objects; +/** + * List sort order, based on creation timestamp + */ +@ApiModel(description = "List sort order, based on creation timestamp") +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2025-01-20T18:58:06.855017776Z[GMT]") + +public class ListQuerySort { + /** + * \"created_at\" is the only allowed field for sorting Lists + */ + @JsonAdapter(FieldEnum.Adapter.class) + public enum FieldEnum { + @SerializedName("created_at") + CREATED_AT("created_at"); + + private String value; + + FieldEnum(String value) { + this.value = value; + } + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static FieldEnum fromValue(String input) { + for (FieldEnum b : FieldEnum.values()) { + if (b.value.equals(input)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final FieldEnum enumeration) throws IOException { + jsonWriter.value(String.valueOf(enumeration.getValue())); + } + + @Override + public FieldEnum read(final JsonReader jsonReader) throws IOException { + Object value = jsonReader.nextString(); + return FieldEnum.fromValue((String)(value)); + } + } + } + @SerializedName("field") + private FieldEnum field = null; + + /** + * Gets or Sets order + */ + @JsonAdapter(OrderEnum.Adapter.class) + public enum OrderEnum { + @SerializedName("asc") + ASC("asc"), + @SerializedName("desc") + DESC("desc"); + + private String value; + + OrderEnum(String value) { + this.value = value; + } + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static OrderEnum fromValue(String input) { + for (OrderEnum b : OrderEnum.values()) { + if (b.value.equals(input)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final OrderEnum enumeration) throws IOException { + jsonWriter.value(String.valueOf(enumeration.getValue())); + } + + @Override + public OrderEnum read(final JsonReader jsonReader) throws IOException { + Object value = jsonReader.nextString(); + return OrderEnum.fromValue((String)(value)); + } + } + } + @SerializedName("order") + private OrderEnum order = null; + + public ListQuerySort field(FieldEnum field) { + this.field = field; + return this; + } + + /** + * \"created_at\" is the only allowed field for sorting Lists + * @return field + **/ + @ApiModelProperty(example = "created_at", required = true, value = "\"created_at\" is the only allowed field for sorting Lists") + public FieldEnum getField() { + return field; + } + + public void setField(FieldEnum field) { + this.field = field; + } + + public ListQuerySort order(OrderEnum order) { + this.order = order; + return this; + } + + /** + * Get order + * @return order + **/ + @ApiModelProperty(example = "asc", required = true, value = "") + public OrderEnum getOrder() { + return order; + } + + public void setOrder(OrderEnum order) { + this.order = order; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListQuerySort listQuerySort = (ListQuerySort) o; + return Objects.equals(this.field, listQuerySort.field) && + Objects.equals(this.order, listQuerySort.order); + } + + @Override + public int hashCode() { + return Objects.hash(field, order); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListQuerySort {\n"); + sb.append(" field: ").append(toIndentedString(field)).append("\n"); + sb.append(" order: ").append(toIndentedString(order)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/io/castle/client/model/generated/ListRequest.java b/src/main/java/io/castle/client/model/generated/ListRequest.java new file mode 100755 index 0000000..5a6a4c3 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/ListRequest.java @@ -0,0 +1,112 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * OpenAPI spec version: 1 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package io.castle.client.model.generated; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + +/** + * ListRequest + */ + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2025-01-20T18:58:06.855017776Z[GMT]") + +public class ListRequest extends BaseList { + @SerializedName("primary_field") + private String primaryField = null; + + @SerializedName("secondary_field") + private String secondaryField = null; + + public ListRequest primaryField(String primaryField) { + this.primaryField = primaryField; + return this; + } + + /** + * Get primaryField + * @return primaryField + **/ + @ApiModelProperty(required = true, value = "") + public String getPrimaryField() { + return primaryField; + } + + public void setPrimaryField(String primaryField) { + this.primaryField = primaryField; + } + + public ListRequest secondaryField(String secondaryField) { + this.secondaryField = secondaryField; + return this; + } + + /** + * Get secondaryField + * @return secondaryField + **/ + @ApiModelProperty(value = "") + public String getSecondaryField() { + return secondaryField; + } + + public void setSecondaryField(String secondaryField) { + this.secondaryField = secondaryField; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListRequest listRequest = (ListRequest) o; + return Objects.equals(this.primaryField, listRequest.primaryField) && + Objects.equals(this.secondaryField, listRequest.secondaryField) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(primaryField, secondaryField, super.hashCode()); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListRequest {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" primaryField: ").append(toIndentedString(primaryField)).append("\n"); + sb.append(" secondaryField: ").append(toIndentedString(secondaryField)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/io/castle/client/model/generated/ListResponse.java b/src/main/java/io/castle/client/model/generated/ListResponse.java new file mode 100644 index 0000000..47b5b53 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/ListResponse.java @@ -0,0 +1,129 @@ +package io.castle.client.model.generated; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import org.threeten.bp.OffsetDateTime; + +import java.util.Objects; + +public class ListResponse extends ListRequest { + @SerializedName("created_at") + private OffsetDateTime createdAt = null; + + @SerializedName("archived_at") + private OffsetDateTime archivedAt = null; + + @SerializedName("id") + private String id = null; + + @SerializedName("size_label") + private String sizeLabel = null; + + @ApiModelProperty(example = "9852", required = false, value = "Size label of the List") + public String getSizeLabel() { + return sizeLabel; + } + + public void setSizeLabel(String sizeLabel) { + this.sizeLabel = sizeLabel; + } + + public ListResponse id(String id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @ApiModelProperty(example = "2ee938c8-24c2-4c26-9d25-19511dd75029", required = true, value = "") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + /** + * Timestamp of when Aggregation was created. + * @return createdAt + **/ + @ApiModelProperty(example = "2022-10-23T17:21:39.213Z", value = "Timestamp of when List was created.") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + public ListResponse createdAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * Timestamp of when Aggregation was archived. + * @return archivedAt + **/ + @ApiModelProperty(example = "2022-10-23T17:21:39.213Z", value = "Timestamp of when List was archived.") + public OffsetDateTime getArchivedAt() { + return archivedAt; + } + + public void setArchivedAt(OffsetDateTime archivedAt) { + this.archivedAt = archivedAt; + } + + public ListResponse archivedAt(OffsetDateTime archivedAt) { + this.archivedAt = createdAt; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListResponse listResponse = (ListResponse) o; + return Objects.equals(this.createdAt, listResponse.createdAt) && + Objects.equals(this.archivedAt, listResponse.archivedAt) && + Objects.equals(this.sizeLabel, listResponse.sizeLabel) && + Objects.equals(this.id, listResponse.id) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(createdAt, archivedAt, sizeLabel, id, super.hashCode()); + } + + + @Override + public String toString() { + String sb = "class ListResponse {\n" + + " " + toIndentedString(super.toString()) + "\n" + + " id: " + toIndentedString(id) + "\n" + + " sizeLabel: " + toIndentedString(sizeLabel) + "\n" + + " createdAt: " + toIndentedString(createdAt) + "\n" + + " archivedAt: " + toIndentedString(archivedAt) + "\n" + + "}"; + return sb; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/io/castle/client/model/generated/Coordinates.java b/src/main/java/io/castle/client/model/generated/Metadata.java old mode 100644 new mode 100755 similarity index 52% rename from src/main/java/io/castle/client/model/generated/Coordinates.java rename to src/main/java/io/castle/client/model/generated/Metadata.java index c7dbe9a..57c02bc --- a/src/main/java/io/castle/client/model/generated/Coordinates.java +++ b/src/main/java/io/castle/client/model/generated/Metadata.java @@ -1,84 +1,70 @@ /* * Castle API - * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. * - * The version of the OpenAPI document: 1 + * OpenAPI spec version: 1 * * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - package io.castle.client.model.generated; import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.util.Objects; /** - * Coordinates + * Metadata is useful for providing additional, structured information on an object. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2023-06-05T10:18:20.077062+02:00[Europe/Stockholm]") -public class Coordinates { - public static final String SERIALIZED_NAME_LAT = "lat"; - @SerializedName(SERIALIZED_NAME_LAT) - private double lat; +@ApiModel(description = "Metadata is useful for providing additional, structured information on an object.") +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2025-01-20T18:58:06.855017776Z[GMT]") - public static final String SERIALIZED_NAME_LON = "lon"; - @SerializedName(SERIALIZED_NAME_LON) - private double lon; +public class Metadata { + @SerializedName("whodunnit") + private String whodunnit = null; + @SerializedName("whodunnit_type") + private AuthorType whodunnitType = null; - public Coordinates lat(double lat) { - - this.lat = lat; + public Metadata whodunnit(String whodunnit) { + this.whodunnit = whodunnit; return this; } /** - * Latitude coordinate - * minimum: -90 - * maximum: 90 - * @return lat + * Get whodunnit + * @return whodunnit **/ - @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "Latitude coordinate") - - public double getLat() { - return lat; + @ApiModelProperty(value = "") + public String getWhodunnit() { + return whodunnit; } - - public void setLat(double lat) { - this.lat = lat; + public void setWhodunnit(String whodunnit) { + this.whodunnit = whodunnit; } - - public Coordinates lon(double lon) { - - this.lon = lon; + public Metadata whodunnitType(AuthorType whodunnitType) { + this.whodunnitType = whodunnitType; return this; } /** - * Longitude coordinate - * minimum: -180 - * maximum: 180 - * @return lon + * Get whodunnitType + * @return whodunnitType **/ - @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "Longitude coordinate") - - public double getLon() { - return lon; + @ApiModelProperty(value = "") + public AuthorType getWhodunnitType() { + return whodunnitType; } - - public void setLon(double lon) { - this.lon = lon; + public void setWhodunnitType(AuthorType whodunnitType) { + this.whodunnitType = whodunnitType; } @@ -90,22 +76,24 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - Coordinates coordinates = (Coordinates) o; - return Objects.equals(this.lat, coordinates.lat) && - Objects.equals(this.lon, coordinates.lon); + Metadata metadata = (Metadata) o; + return Objects.equals(this.whodunnit, metadata.whodunnit) && + Objects.equals(this.whodunnitType, metadata.whodunnitType); } @Override public int hashCode() { - return Objects.hash(lat, lon); + return Objects.hash(whodunnit, whodunnitType); } + @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class Coordinates {\n"); - sb.append(" lat: ").append(toIndentedString(lat)).append("\n"); - sb.append(" lon: ").append(toIndentedString(lon)).append("\n"); + sb.append("class Metadata {\n"); + + sb.append(" whodunnit: ").append(toIndentedString(whodunnit)).append("\n"); + sb.append(" whodunnitType: ").append(toIndentedString(whodunnitType)).append("\n"); sb.append("}"); return sb.toString(); } @@ -122,4 +110,3 @@ private String toIndentedString(Object o) { } } - diff --git a/src/main/java/io/castle/client/model/generated/Op.java b/src/main/java/io/castle/client/model/generated/Op.java new file mode 100755 index 0000000..2d26415 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/Op.java @@ -0,0 +1,107 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our APIs implement rate-limiting based on the number of requests made to them. Each request will return the following headers: - `X-RateLimit-Limit` - The maximum number of requests you're permitted to make in the current time window. - `X-RateLimit-Remaining` - The number of requests remaining in the current time window. - `X-RateLimit-Reset` - The remaining time in seconds until the current time window resets. Additionally, Our Risk, Filter (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * OpenAPI spec version: 1 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package io.castle.client.model.generated; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +import java.io.IOException; + +/** + * Gets or Sets Op + */ +@JsonAdapter(Op.Adapter.class) +public enum Op { + @SerializedName("$eq") + EQ("$eq"), + @SerializedName("$neq") + NEQ("$neq"), + @SerializedName("$in") + IN("$in"), + @SerializedName("$nin") + NIN("$nin"), + @SerializedName("$range") + RANGE("$range"), + @SerializedName("$exists") + EXISTS("$exists"), + @SerializedName("$nexists") + NEXISTS("$nexists"), + @SerializedName("$geo") + GEO("$geo"), + @SerializedName("$like") + LIKE("$like"), + @SerializedName("$nlike") + NLIKE("$nlike"), + @SerializedName("$contains") + CONTAINS("$contains"), + @SerializedName("$ncontains") + NCONTAINS("$ncontains"), + @SerializedName("$starts_with") + STARTS_WITH("$starts_with"), + @SerializedName("$nstarts_with") + NSTARTS_WITH("$nstarts_with"), + @SerializedName("$ends_with") + ENDS_WITH("$ends_with"), + @SerializedName("$nends_with") + NENDS_WITH("$nends_with"), + @SerializedName("$matches") + MATCHES("$matches"), + @SerializedName("$nmatches") + NMATCHES("$nmatches"), + @SerializedName("$ip_range") + IP_RANGE("$ip_range"), + @SerializedName("$nip_range") + NIP_RANGE("$nip_range"), + @SerializedName("$or") + OR("$or"); + + private String value; + + Op(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static Op fromValue(String input) { + for (Op b : Op.values()) { + if (b.value.equals(input)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final Op enumeration) throws IOException { + jsonWriter.value(String.valueOf(enumeration.getValue())); + } + + @Override + public Op read(final JsonReader jsonReader) throws IOException { + Object value = jsonReader.nextString(); + return Op.fromValue((String)(value)); + } + } +} diff --git a/src/test/java/io/castle/client/CastleListItemsTest.java b/src/test/java/io/castle/client/CastleListItemsTest.java new file mode 100644 index 0000000..fb615dd --- /dev/null +++ b/src/test/java/io/castle/client/CastleListItemsTest.java @@ -0,0 +1,333 @@ +package io.castle.client; + +import io.castle.client.model.AuthenticateAction; +import io.castle.client.model.AuthenticateFailoverStrategy; +import io.castle.client.model.CastleResponse; +import io.castle.client.model.generated.*; +import jakarta.servlet.http.HttpServletRequest; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.RecordedRequest; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.mock.web.MockHttpServletRequest; +import org.threeten.bp.OffsetDateTime; + +import java.util.ArrayList; +import java.util.List; + +public class CastleListItemsTest extends AbstractCastleHttpLayerTest { + + public CastleListItemsTest() { + super(new AuthenticateFailoverStrategy(AuthenticateAction.CHALLENGE)); + } + + @Test + public void createListItem() throws InterruptedException { + MockResponse mockResponse = new MockResponse(); + mockResponse.setBody("{\n" + + " \"primary_value\": \"A04t7AcfSA69cBTTusx0RQ\",\n" + + " \"secondary_value\": \"2ee938c8-24c2-4c26-9d25-19511dd75029\",\n" + + " \"comment\": \"Fradulent user found through manual inspection\",\n" + + " \"author\": {\n" + + " \"type\": \"$analyst_email\",\n" + + " \"identifier\": \"string\"\n" + + " },\n" + + " \"auto_archives_at\": \"2021-09-27T16:46:38.313Z\",\n" + + " \"id\": \"2ee938c8-24c2-4c26-9d25-19511dd75029\",\n" + + " \"list_id\": \"2ee938c8-24c2-4c26-9d25-19511dd75029\",\n" + + " \"archived\": true,\n" + + " \"created_at\": \"2021-09-27T16:46:38.313Z\"\n" + + "}"); + mockResponse.setResponseCode(201); + server.enqueue(mockResponse); + + // And a mock Request + HttpServletRequest request = new MockHttpServletRequest(); + + ListItemRequest listItem = createListItemRequest(); + + ListItem response = sdk.onRequest(request).createListItem("2ee938c8-24c2-4c26-9d25-19511dd75029", listItem); + + // Check response object + Assert.assertEquals("A04t7AcfSA69cBTTusx0RQ", response.getPrimaryValue()); + Assert.assertEquals("2ee938c8-24c2-4c26-9d25-19511dd75029", response.getSecondaryValue()); + Assert.assertEquals("Fradulent user found through manual inspection", response.getComment()); + Assert.assertEquals("2ee938c8-24c2-4c26-9d25-19511dd75029", response.getId()); + Assert.assertEquals("2ee938c8-24c2-4c26-9d25-19511dd75029", response.getListId()); + Assert.assertTrue(response.isArchived()); + Assert.assertEquals(OffsetDateTime.parse("2021-09-27T16:46:38.313Z"), response.getCreatedAt()); + Assert.assertEquals(OffsetDateTime.parse("2021-09-27T16:46:38.313Z"), response.getAutoArchivesAt()); + Assert.assertEquals(AuthorType.ANALYST_EMAIL, response.getAuthor().getType()); + Assert.assertEquals("string", response.getAuthor().getIdentifier()); + + // Then + RecordedRequest recordedRequest = server.takeRequest(); + Assert.assertEquals(testServerBaseUrl.resolve(String.format("v1/lists/%s/items", "2ee938c8-24c2-4c26-9d25-19511dd75029")), recordedRequest.getRequestUrl()); + Assert.assertEquals("POST", recordedRequest.getMethod()); + } + + @Test + public void createOrUpdateListItems() throws InterruptedException { + MockResponse mockResponse = new MockResponse(); + mockResponse.setBody("{\n" + + " \"total_received\": 135,\n" + + " \"total_processed\": 130,\n" + + " \"errored\": 5,\n" + + " \"replaced\": 10,\n" + + " \"updated\": 20,\n" + + " \"created\": 100\n" + + "}"); + mockResponse.setResponseCode(201); + server.enqueue(mockResponse); + + // And a mock Request + HttpServletRequest request = new MockHttpServletRequest(); + + ListItemsBatchRequest items = createListItemBulkRequest(); + + ListItemsBatchResponse response = sdk.onRequest(request).createOrUpdateListItems("2ee938c8-24c2-4c26-9d25-19511dd75029", items); + + // Check response object + Assert.assertEquals(135, response.getTotalReceived()); + Assert.assertEquals(130, response.getTotalProcessed()); + Assert.assertEquals(5, response.getErrored()); + Assert.assertEquals(10, response.getReplaced()); + Assert.assertEquals(20, response.getUpdated()); + Assert.assertEquals(100, response.getCreated()); + + // Then + RecordedRequest recordedRequest = server.takeRequest(); + Assert.assertEquals(testServerBaseUrl.resolve(String.format("v1/lists/%s/items/batch", "2ee938c8-24c2-4c26-9d25-19511dd75029")), recordedRequest.getRequestUrl()); + Assert.assertEquals("POST", recordedRequest.getMethod()); + } + + @Test + public void searchListItems() throws InterruptedException { + MockResponse mockResponse = new MockResponse(); + mockResponse.setBody("[\n" + + "{\n" + + "\"primary_value\": \"A04t7AcfSA69cBTTusx0RQ\",\n" + + "\"secondary_value\": \"2ee938c8-24c2-4c26-9d25-19511dd75029\",\n" + + "\"comment\": \"Fradulent user found through manual inspection\",\n" + + "\"author\": {\n" + + "\"type\": \"$analyst_email\",\n" + + "\"identifier\": \"string\"\n" + + "},\n" + + "\"auto_archives_at\": \"2021-09-27T16:46:38.313Z\",\n" + + "\"id\": \"2ee938c8-24c2-4c26-9d25-19511dd75029\",\n" + + "\"list_id\": \"2ee938c8-24c2-4c26-9d25-19511dd75029\",\n" + + "\"archived\": true,\n" + + "\"created_at\": \"2021-09-27T16:46:38.313Z\"\n" + + "}\n" + + "]"); + mockResponse.setResponseCode(200); + server.enqueue(mockResponse); + + // And a mock Request + HttpServletRequest request = new MockHttpServletRequest(); + + ListItemQuery listItemQuery = new ListItemQuery(); + listItemQuery.page(1); + listItemQuery.resultsSize(50); + + List filters = new ArrayList<>(); + filters.add(new ListItemQueryFilter().field(ListItemQueryFilter.FieldEnum.PRIMARY_VALUE).op(ListItemQueryFilter.OpEnum._EQ).value("Uc80JFKRRvm")); + filters.add(new ListItemQueryFilter().field(ListItemQueryFilter.FieldEnum.ARCHIVED).op(ListItemQueryFilter.OpEnum._EQ).value(false)); + filters.add(new ListItemQueryOrFilter().op(ListItemQueryOrFilter.OpEnum._OR).value(List.of(new ListItemQueryFilter().field(ListItemQueryFilter.FieldEnum.SECONDARY_VALUE).op(ListItemQueryFilter.OpEnum._EQ).value("1")))); + listItemQuery.filters(filters); + + List response = sdk.onRequest(request).searchListItems("2ee938c8-24c2-4c26-9d25-19511dd75029", listItemQuery); + + // Check response object + Assert.assertEquals(1, response.size()); + ListItem listItem = response.get(0); + Assert.assertEquals("A04t7AcfSA69cBTTusx0RQ", listItem.getPrimaryValue()); + Assert.assertEquals("2ee938c8-24c2-4c26-9d25-19511dd75029", listItem.getSecondaryValue()); + Assert.assertEquals("Fradulent user found through manual inspection", listItem.getComment()); + Assert.assertEquals("2ee938c8-24c2-4c26-9d25-19511dd75029", listItem.getId()); + Assert.assertEquals("2ee938c8-24c2-4c26-9d25-19511dd75029", listItem.getListId()); + Assert.assertTrue(listItem.isArchived()); + Assert.assertEquals(OffsetDateTime.parse("2021-09-27T16:46:38.313Z"), listItem.getCreatedAt()); + Assert.assertEquals(OffsetDateTime.parse("2021-09-27T16:46:38.313Z"), listItem.getAutoArchivesAt()); + Assert.assertEquals(AuthorType.ANALYST_EMAIL, listItem.getAuthor().getType()); + Assert.assertEquals("string", listItem.getAuthor().getIdentifier()); + + // Then + RecordedRequest recordedRequest = server.takeRequest(); + Assert.assertEquals(testServerBaseUrl.resolve(String.format("v1/lists/%s/items/query", "2ee938c8-24c2-4c26-9d25-19511dd75029")), recordedRequest.getRequestUrl()); + Assert.assertEquals("POST", recordedRequest.getMethod()); + } + + @Test + public void countListItems() throws InterruptedException { + MockResponse mockResponse = new MockResponse(); + mockResponse.setBody("{\n" + + " \"total_count\": 1\n" + + "}"); + mockResponse.setResponseCode(200); + server.enqueue(mockResponse); + + // And a mock Request + HttpServletRequest request = new MockHttpServletRequest(); + + ListItemQuery listItemQuery = new ListItemQuery(); + List filters = new ArrayList<>(); + filters.add(new ListItemQueryFilter().field(ListItemQueryFilter.FieldEnum.PRIMARY_VALUE).op(ListItemQueryFilter.OpEnum._EQ).value("Uc80JFKRRvm")); + filters.add(new ListItemQueryFilter().field(ListItemQueryFilter.FieldEnum.ARCHIVED).op(ListItemQueryFilter.OpEnum._EQ).value(false)); + filters.add(new ListItemQueryOrFilter().op(ListItemQueryOrFilter.OpEnum._OR).value(List.of(new ListItemQueryFilter().field(ListItemQueryFilter.FieldEnum.SECONDARY_VALUE).op(ListItemQueryFilter.OpEnum._EQ).value("1")))); + filters.add(new ListItemQueryOrFilter().op(ListItemQueryOrFilter.OpEnum._OR).value(List.of(new ListItemQueryFilter().field(ListItemQueryFilter.FieldEnum.SECONDARY_VALUE).op(ListItemQueryFilter.OpEnum._EQ).value("2")))); + listItemQuery.filters(filters); + + ListItemListCount response = sdk.onRequest(request).countListItems("2ee938c8-24c2-4c26-9d25-19511dd75029", listItemQuery); + + // Check response object + Assert.assertEquals(1, response.getTotalCount()); + + // Then + RecordedRequest recordedRequest = server.takeRequest(); + Assert.assertEquals(testServerBaseUrl.resolve(String.format("v1/lists/%s/items/count", "2ee938c8-24c2-4c26-9d25-19511dd75029")), recordedRequest.getRequestUrl()); + Assert.assertEquals("POST", recordedRequest.getMethod()); + } + + @Test + public void updateListItem() throws InterruptedException { + MockResponse mockResponse = new MockResponse(); + mockResponse.setBody("{\n" + + " \"primary_value\": \"A04t7AcfSA69cBTTusx0RQ\",\n" + + " \"secondary_value\": \"2ee938c8-24c2-4c26-9d25-19511dd75029\",\n" + + " \"comment\": \"Listed due to manual investigation\",\n" + + " \"author\": {\n" + + " \"type\": \"$analyst_email\",\n" + + " \"identifier\": \"string\"\n" + + " },\n" + + " \"auto_archives_at\": \"2021-09-27T16:46:38.313Z\",\n" + + " \"id\": \"2ee938c8-24c2-4c26-9d25-19511dd75029\",\n" + + " \"list_id\": \"2ee938c8-24c2-4c26-9d25-19511dd75029\",\n" + + " \"archived\": true,\n" + + " \"created_at\": \"2021-09-27T16:46:38.313Z\"\n" + + "}"); + mockResponse.setResponseCode(201); + server.enqueue(mockResponse); + + // And a mock Request + HttpServletRequest request = new MockHttpServletRequest(); + + ListItemRequest listItem = new ListItemRequest(); + listItem.comment("Listed due to manual investigation"); + + ListItem response = sdk.onRequest(request).updateListItem("2ee938c8-24c2-4c26-9d25-19511dd75029", "2ee938c8-24c2-4c26-9d25-19511dd75029", listItem); + + // Check response object + Assert.assertEquals("A04t7AcfSA69cBTTusx0RQ", response.getPrimaryValue()); + Assert.assertEquals("2ee938c8-24c2-4c26-9d25-19511dd75029", response.getSecondaryValue()); + Assert.assertEquals("Listed due to manual investigation", response.getComment()); + Assert.assertEquals("2ee938c8-24c2-4c26-9d25-19511dd75029", response.getId()); + Assert.assertEquals("2ee938c8-24c2-4c26-9d25-19511dd75029", response.getListId()); + Assert.assertTrue(response.isArchived()); + Assert.assertEquals(OffsetDateTime.parse("2021-09-27T16:46:38.313Z"), response.getCreatedAt()); + Assert.assertEquals(OffsetDateTime.parse("2021-09-27T16:46:38.313Z"), response.getAutoArchivesAt()); + Assert.assertEquals(AuthorType.ANALYST_EMAIL, response.getAuthor().getType()); + Assert.assertEquals("string", response.getAuthor().getIdentifier()); + + // Then + RecordedRequest recordedRequest = server.takeRequest(); + Assert.assertEquals(testServerBaseUrl.resolve(String.format("v1/lists/%s/items/%s", "2ee938c8-24c2-4c26-9d25-19511dd75029", "2ee938c8-24c2-4c26-9d25-19511dd75029")), recordedRequest.getRequestUrl()); + Assert.assertEquals("POST", recordedRequest.getMethod()); + } + + @Test + public void getListItem() throws InterruptedException { + MockResponse mockResponse = new MockResponse(); + mockResponse.setBody("{\n" + + " \"primary_value\": \"A04t7AcfSA69cBTTusx0RQ\",\n" + + " \"secondary_value\": \"2ee938c8-24c2-4c26-9d25-19511dd75029\",\n" + + " \"comment\": \"Fradulent user found through manual inspection\",\n" + + " \"author\": {\n" + + " \"type\": \"$analyst_email\",\n" + + " \"identifier\": \"string\"\n" + + " },\n" + + " \"auto_archives_at\": \"2021-09-27T16:46:38.313Z\",\n" + + " \"id\": \"2ee938c8-24c2-4c26-9d25-19511dd75029\",\n" + + " \"list_id\": \"2ee938c8-24c2-4c26-9d25-19511dd75029\",\n" + + " \"archived\": true,\n" + + " \"created_at\": \"2021-09-27T16:46:38.313Z\"\n" + + "}"); + mockResponse.setResponseCode(200); + server.enqueue(mockResponse); + + // And a mock Request + HttpServletRequest request = new MockHttpServletRequest(); + + ListItem response = sdk.onRequest(request).getListItem("2ee938c8-24c2-4c26-9d25-19511dd75029", "2ee938c8-24c2-4c26-9d25-19511dd75029"); + + // Check response object + Assert.assertEquals("A04t7AcfSA69cBTTusx0RQ", response.getPrimaryValue()); + Assert.assertEquals("2ee938c8-24c2-4c26-9d25-19511dd75029", response.getSecondaryValue()); + Assert.assertEquals("Fradulent user found through manual inspection", response.getComment()); + Assert.assertEquals("2ee938c8-24c2-4c26-9d25-19511dd75029", response.getId()); + Assert.assertEquals("2ee938c8-24c2-4c26-9d25-19511dd75029", response.getListId()); + Assert.assertTrue(response.isArchived()); + Assert.assertEquals(OffsetDateTime.parse("2021-09-27T16:46:38.313Z"), response.getCreatedAt()); + Assert.assertEquals(OffsetDateTime.parse("2021-09-27T16:46:38.313Z"), response.getAutoArchivesAt()); + Assert.assertEquals(AuthorType.ANALYST_EMAIL, response.getAuthor().getType()); + Assert.assertEquals("string", response.getAuthor().getIdentifier()); + + // Then + RecordedRequest recordedRequest = server.takeRequest(); + Assert.assertEquals(testServerBaseUrl.resolve(String.format("v1/lists/%s/items/%s", "2ee938c8-24c2-4c26-9d25-19511dd75029", "2ee938c8-24c2-4c26-9d25-19511dd75029")), recordedRequest.getRequestUrl()); + Assert.assertEquals("GET", recordedRequest.getMethod()); + } + + @Test + public void achiveListItem() throws InterruptedException { + MockResponse mockResponse = new MockResponse(); + mockResponse.setResponseCode(200); + server.enqueue(mockResponse); + + // And a mock Request + HttpServletRequest request = new MockHttpServletRequest(); + + CastleResponse response = sdk.onRequest(request).archiveListItem("2ee938c8-24c2-4c26-9d25-19511dd75029", "2ee938c8-24c2-4c26-9d25-19511dd75029"); + + // Then + RecordedRequest recordedRequest = server.takeRequest(); + Assert.assertEquals(testServerBaseUrl.resolve(String.format("v1/lists/%s/items/%s/archive", "2ee938c8-24c2-4c26-9d25-19511dd75029", "2ee938c8-24c2-4c26-9d25-19511dd75029")), recordedRequest.getRequestUrl()); + Assert.assertEquals("DELETE", recordedRequest.getMethod()); + } + + @Test + public void unachiveListItem() throws InterruptedException { + MockResponse mockResponse = new MockResponse(); + mockResponse.setResponseCode(200); + server.enqueue(mockResponse); + + // And a mock Request + HttpServletRequest request = new MockHttpServletRequest(); + + CastleResponse response = sdk.onRequest(request).unarchiveListItem("2ee938c8-24c2-4c26-9d25-19511dd75029", "2ee938c8-24c2-4c26-9d25-19511dd75029"); + + // Then + RecordedRequest recordedRequest = server.takeRequest(); + Assert.assertEquals(testServerBaseUrl.resolve(String.format("v1/lists/%s/items/%s/unarchive", "2ee938c8-24c2-4c26-9d25-19511dd75029", "2ee938c8-24c2-4c26-9d25-19511dd75029")), recordedRequest.getRequestUrl()); + Assert.assertEquals("PUT", recordedRequest.getMethod()); + } + + private ListItemsBatchRequest createListItemBulkRequest() { + ListItemsBatchRequest listItemsBatchRequest = new ListItemsBatchRequest(); + listItemsBatchRequest.setItems(List.of(createListItemRequest())); + return listItemsBatchRequest; + } + + private ListItemRequest createListItemRequest() { + ListItemRequest listItem = new ListItemRequest(); + listItem.primaryValue("A04t7AcfSA69cBTTusx0RQ"); + listItem.secondaryValue("2ee938c8-24c2-4c26-9d25-19511dd75029"); + listItem.comment("Fradulent user found through manual inspection"); + listItem.author(new ListItemAuthor().type(AuthorType.ANALYST_EMAIL).identifier("string")); + listItem.autoArchivesAt(OffsetDateTime.parse("2021-09-27T16:46:38.313Z")); + listItem.mode(ListItemRequest.ModeEnum.ERROR); + return listItem; + } + + +} diff --git a/src/test/java/io/castle/client/CastleListsHttpTest.java b/src/test/java/io/castle/client/CastleListsHttpTest.java new file mode 100644 index 0000000..18886cc --- /dev/null +++ b/src/test/java/io/castle/client/CastleListsHttpTest.java @@ -0,0 +1,423 @@ +package io.castle.client; + +import com.google.gson.JsonParser; +import io.castle.client.internal.json.CastleGsonModel; +import io.castle.client.model.AuthenticateAction; +import io.castle.client.model.AuthenticateFailoverStrategy; +import io.castle.client.model.generated.*; +import jakarta.servlet.http.HttpServletRequest; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.RecordedRequest; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.mock.web.MockHttpServletRequest; +import org.threeten.bp.OffsetDateTime; + +import java.util.ArrayList; +import java.util.List; + +public class CastleListsHttpTest extends AbstractCastleHttpLayerTest { + + public CastleListsHttpTest() { + super(new AuthenticateFailoverStrategy(AuthenticateAction.CHALLENGE)); + } + + @Test + public void updateList() throws InterruptedException { + MockResponse mockResponse = new MockResponse(); + mockResponse.setBody("{\n" + + " \"name\": \"Malicious IPs\",\n" + + " \"description\": \"We block these IPs from withdrawing funds. Please be careful.\",\n" + + " \"color\": \"$red\",\n" + + " \"default_item_archivation_time\": 2592000,\n" + + " \"id\": \"2ee938c8-24c2-4c26-9d25-19511dd75029\",\n" + + " \"primary_field\": \"device.fingerprint\",\n" + + " \"secondary_field\": \"ip.value\",\n" + + " \"archived_at\": \"2021-09-27T16:46:38.313Z\",\n" + + " \"created_at\": \"2021-09-27T16:46:38.313Z\"\n" + + "}"); + mockResponse.setResponseCode(201); + server.enqueue(mockResponse); + + // Add a mock Request + HttpServletRequest request = new MockHttpServletRequest(); + + ListRequest list = createListRequest(); + + ListResponse response = sdk.onRequest(request).updateList("2ee938c8-24c2-4c26-9d25-19511dd75029", list); + + // Check response object + Assert.assertEquals("Malicious IPs", response.getName()); + Assert.assertEquals("We block these IPs from withdrawing funds. Please be careful.", response.getDescription()); + Assert.assertEquals(ListColor.RED, response.getColor()); + Assert.assertEquals(2592000, response.getDefaultItemArchivationTime()); + Assert.assertEquals("2ee938c8-24c2-4c26-9d25-19511dd75029", response.getId()); + Assert.assertEquals("device.fingerprint", response.getPrimaryField()); + Assert.assertEquals("ip.value", response.getSecondaryField()); + Assert.assertEquals(OffsetDateTime.parse("2021-09-27T16:46:38.313Z"), response.getArchivedAt()); + Assert.assertEquals(OffsetDateTime.parse("2021-09-27T16:46:38.313Z"), response.getCreatedAt()); + + // Then + RecordedRequest recordedRequest = server.takeRequest(); + Assert.assertEquals(testServerBaseUrl.resolve(String.format("v1/lists/%s", "2ee938c8-24c2-4c26-9d25-19511dd75029")), recordedRequest.getRequestUrl()); + Assert.assertEquals("PUT", recordedRequest.getMethod()); + } + + @Test + public void listAllLists() throws InterruptedException { + MockResponse mockResponse = new MockResponse(); + mockResponse.setBody("[\n" + + " {\n" + + " \"name\": \"Malicious IPs\",\n" + + " \"description\": \"We block these IPs from withdrawing funds. Please be careful.\",\n" + + " \"color\": \"$red\",\n" + + " \"default_item_archivation_time\": 2592000,\n" + + " \"id\": \"2ee938c8-24c2-4c26-9d25-19511dd75029\",\n" + + " \"primary_field\": \"device.fingerprint\",\n" + + " \"secondary_field\": \"ip.value\",\n" + + " \"archived_at\": \"2021-09-27T16:46:38.313Z\",\n" + + " \"created_at\": \"2021-09-27T16:46:38.313Z\"\n" + + " }\n" + + "]"); + mockResponse.setResponseCode(200); + server.enqueue(mockResponse); + + // And a mock Request + HttpServletRequest request = new MockHttpServletRequest(); + + List response = sdk.onRequest(request).listAllLists(); + + // Check response object + Assert.assertEquals(1, response.size()); + ListResponse list = response.get(0); + Assert.assertEquals("Malicious IPs", list.getName()); + Assert.assertEquals("We block these IPs from withdrawing funds. Please be careful.", list.getDescription()); + Assert.assertEquals(ListColor.RED, list.getColor()); + Assert.assertEquals(2592000, list.getDefaultItemArchivationTime()); + Assert.assertEquals("2ee938c8-24c2-4c26-9d25-19511dd75029", list.getId()); + Assert.assertEquals("device.fingerprint", list.getPrimaryField()); + Assert.assertEquals("ip.value", list.getSecondaryField()); + Assert.assertEquals(OffsetDateTime.parse("2021-09-27T16:46:38.313Z"), list.getArchivedAt()); + Assert.assertEquals(OffsetDateTime.parse("2021-09-27T16:46:38.313Z"), list.getCreatedAt()); + + // Then + RecordedRequest recordedRequest = server.takeRequest(); + Assert.assertEquals(testServerBaseUrl.resolve("v1/lists"), recordedRequest.getRequestUrl()); + Assert.assertEquals("GET", recordedRequest.getMethod()); + } + + @Test public void getList() throws InterruptedException { + MockResponse mockResponse = new MockResponse(); + mockResponse.setBody("{\n" + + " \"name\": \"Malicious IPs\",\n" + + " \"description\": \"We block these IPs from withdrawing funds. Please be careful.\",\n" + + " \"color\": \"$red\",\n" + + " \"default_item_archivation_time\": 2592000,\n" + + " \"id\": \"2ee938c8-24c2-4c26-9d25-19511dd75029\",\n" + + " \"primary_field\": \"device.fingerprint\",\n" + + " \"secondary_field\": \"ip.value\",\n" + + " \"archived_at\": \"2021-09-27T16:46:38.313Z\",\n" + + " \"created_at\": \"2021-09-27T16:46:38.313Z\"\n" + + "}"); + mockResponse.setResponseCode(200); + server.enqueue(mockResponse); + + // And a mock Request + HttpServletRequest request = new MockHttpServletRequest(); + + ListRequest list = createListRequest(); + + ListResponse response = sdk.onRequest(request).list("2ee938c8-24c2-4c26-9d25-19511dd75029"); + + // Check response object + Assert.assertEquals("Malicious IPs", response.getName()); + Assert.assertEquals("We block these IPs from withdrawing funds. Please be careful.", response.getDescription()); + Assert.assertEquals(ListColor.RED, response.getColor()); + Assert.assertEquals(2592000, response.getDefaultItemArchivationTime()); + Assert.assertEquals("2ee938c8-24c2-4c26-9d25-19511dd75029", response.getId()); + Assert.assertEquals("device.fingerprint", response.getPrimaryField()); + Assert.assertEquals("ip.value", response.getSecondaryField()); + Assert.assertEquals(OffsetDateTime.parse("2021-09-27T16:46:38.313Z"), response.getArchivedAt()); + Assert.assertEquals(OffsetDateTime.parse("2021-09-27T16:46:38.313Z"), response.getCreatedAt()); + + // Then + RecordedRequest recordedRequest = server.takeRequest(); + Assert.assertEquals(testServerBaseUrl.resolve(String.format("v1/lists/%s", "2ee938c8-24c2-4c26-9d25-19511dd75029")), recordedRequest.getRequestUrl()); + Assert.assertEquals("GET", recordedRequest.getMethod()); + } + + @Test + public void deleteList() throws InterruptedException { + MockResponse mockResponse = new MockResponse(); + mockResponse.setResponseCode(204); + server.enqueue(mockResponse); + + // And a mock Request + HttpServletRequest request = new MockHttpServletRequest(); + + sdk.onRequest(request).deleteList("2ee938c8-24c2-4c26-9d25-19511dd75029"); + + // Then + RecordedRequest recordedRequest = server.takeRequest(); + Assert.assertEquals(testServerBaseUrl.resolve(String.format("v1/lists/%s", "2ee938c8-24c2-4c26-9d25-19511dd75029")), recordedRequest.getRequestUrl()); + Assert.assertEquals("DELETE", recordedRequest.getMethod()); + } + + @Test + public void searchList() throws InterruptedException { + MockResponse mockResponse = new MockResponse(); + mockResponse.setBody("[\n" + + " {\n" + + " \"name\": \"Malicious IPs\",\n" + + " \"description\": \"We block these IPs from withdrawing funds. Please be careful.\",\n" + + " \"color\": \"$red\",\n" + + " \"default_item_archivation_time\": 2592000,\n" + + " \"id\": \"2ee938c8-24c2-4c26-9d25-19511dd75029\",\n" + + " \"primary_field\": \"device.fingerprint\",\n" + + " \"secondary_field\": \"ip.value\",\n" + + " \"archived_at\": \"2021-09-27T16:46:38.313Z\",\n" + + " \"created_at\": \"2021-09-27T16:46:38.313Z\",\n" + + " \"size_label\": \"9852\"\n" + + " }\n" + + "]"); + mockResponse.setResponseCode(200); + server.enqueue(mockResponse); + + // And a mock Request + HttpServletRequest request = new MockHttpServletRequest(); + + ListQuery query = createListQuery(); + + List response = sdk.onRequest(request).searchLists(query); + + // Check response object + Assert.assertEquals(1, response.size()); + ListResponse list = response.get(0); + Assert.assertEquals("Malicious IPs", list.getName()); + Assert.assertEquals("We block these IPs from withdrawing funds. Please be careful.", list.getDescription()); + Assert.assertEquals(ListColor.RED, list.getColor()); + Assert.assertEquals(2592000, list.getDefaultItemArchivationTime()); + Assert.assertEquals("2ee938c8-24c2-4c26-9d25-19511dd75029", list.getId()); + Assert.assertEquals("device.fingerprint", list.getPrimaryField()); + Assert.assertEquals("ip.value", list.getSecondaryField()); + Assert.assertEquals(OffsetDateTime.parse("2021-09-27T16:46:38.313Z"), list.getArchivedAt()); + Assert.assertEquals(OffsetDateTime.parse("2021-09-27T16:46:38.313Z"), list.getCreatedAt()); + Assert.assertEquals("9852", list.getSizeLabel()); + + // Then + RecordedRequest recordedRequest = server.takeRequest(); + Assert.assertEquals(testServerBaseUrl.resolve("v1/lists/query"), recordedRequest.getRequestUrl()); + Assert.assertEquals("POST", recordedRequest.getMethod()); + } + + @Test + public void createList() throws InterruptedException { + MockResponse mockResponse = new MockResponse(); + mockResponse.setBody("{\n" + + " \"name\": \"Malicious IPs\",\n" + + " \"description\": \"We block these IPs from withdrawing funds. Please be careful.\",\n" + + " \"color\": \"$red\",\n" + + " \"default_item_archivation_time\": 2592000,\n" + + " \"id\": \"2ee938c8-24c2-4c26-9d25-19511dd75029\",\n" + + " \"primary_field\": \"device.fingerprint\",\n" + + " \"secondary_field\": \"ip.value\",\n" + + " \"archived_at\": \"2021-09-27T16:46:38.313Z\",\n" + + " \"created_at\": \"2021-09-27T16:46:38.313Z\"\n" + + "}"); + mockResponse.setResponseCode(201); + server.enqueue(mockResponse); + + // And a mock Request + HttpServletRequest request = new MockHttpServletRequest(); + + ListRequest list = createListRequest(); + + ListResponse response = sdk.onRequest(request).createList(list); + + // Check response object + Assert.assertEquals("Malicious IPs", response.getName()); + Assert.assertEquals("We block these IPs from withdrawing funds. Please be careful.", response.getDescription()); + Assert.assertEquals(ListColor.RED, response.getColor()); + Assert.assertEquals(2592000, response.getDefaultItemArchivationTime()); + Assert.assertEquals("2ee938c8-24c2-4c26-9d25-19511dd75029", response.getId()); + Assert.assertEquals("device.fingerprint", response.getPrimaryField()); + Assert.assertEquals("ip.value", response.getSecondaryField()); + Assert.assertEquals(OffsetDateTime.parse("2021-09-27T16:46:38.313Z"), response.getArchivedAt()); + Assert.assertEquals(OffsetDateTime.parse("2021-09-27T16:46:38.313Z"), response.getCreatedAt()); + + // Then + RecordedRequest recordedRequest = server.takeRequest(); + Assert.assertEquals(testServerBaseUrl.resolve("v1/lists"), recordedRequest.getRequestUrl()); + Assert.assertEquals("POST", recordedRequest.getMethod()); + } + + private ListQuery createListQuery() { + ListQuery query = new ListQuery(); + query.page(2); + query.resultsSize(50); + query.includeSizeLabel(true); + + ListQuerySort sort = new ListQuerySort(); + sort.field(ListQuerySort.FieldEnum.CREATED_AT); + sort.order(ListQuerySort.OrderEnum.ASC); + query.sort(sort); + + List filters = new ArrayList<>(); + + ListQueryFilter filter = new ListQueryFilter(); + filter.field(ListQueryFilter.FieldEnum.PRIMARY_FIELD); + filter.op(ListQueryFilter.OpEnum._EQ); + filter.value("device.fingerprint"); + filters.add(filter); + + filter = new ListQueryFilter(); + filter.field(ListQueryFilter.FieldEnum.ARCHIVED); + filter.op(ListQueryFilter.OpEnum._EQ); + filter.value(false); + filters.add(filter); + + ListQueryOrFilter orFilter = new ListQueryOrFilter(); + orFilter.op(ListQueryOrFilter.OpEnum._OR); + orFilter.value(List.of(new ListQueryFilter().field(ListQueryFilter.FieldEnum.SECONDARY_FIELD).op(ListQueryFilter.OpEnum._EQ).value("user.id"))); + filters.add(orFilter); + + orFilter = new ListQueryOrFilter(); + orFilter.op(ListQueryOrFilter.OpEnum._OR); + orFilter.value(List.of(new ListQueryFilter().field(ListQueryFilter.FieldEnum.SECONDARY_FIELD).op(ListQueryFilter.OpEnum._EQ).value("user.email"))); + filters.add(orFilter); + + query.filters(filters); + + query.sort(new ListQuerySort().field(ListQuerySort.FieldEnum.CREATED_AT).order(ListQuerySort.OrderEnum.ASC)); + + return query; + } + + @Test + public void compareListQueryJson() { + ListQuery listQuery = createListQuery(); + + // Convert list query object to JSON + CastleGsonModel gson = new CastleGsonModel(); + String listJson = gson.getGson().toJson(listQuery); + + // Provided JSON + String providedJson = "{\n" + + " \"filters\": [\n" + + " {\n" + + " \"field\": \"primary_field\",\n" + + " \"op\": \"$eq\",\n" + + " \"value\": \"device.fingerprint\"\n" + + " },\n" + + " {\n" + + " \"field\": \"archived\",\n" + + " \"op\": \"$eq\",\n" + + " \"value\": false\n" + + " },\n" + + " {\n" + + " \"op\": \"$or\",\n" + + " \"value\": [\n" + + " {\n" + + " \"field\": \"secondary_field\",\n" + + " \"op\": \"$eq\",\n" + + " \"value\": \"user.id\"\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"op\": \"$or\",\n" + + " \"value\": [\n" + + " {\n" + + " \"field\": \"secondary_field\",\n" + + " \"op\": \"$eq\",\n" + + " \"value\": \"user.email\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"page\": 2,\n" + + " \"results_size\": 50,\n" + + " \"include_size_label\": true,\n" + + " \"sort\": {\n" + + " \"field\": \"created_at\",\n" + + " \"order\": \"asc\"\n" + + " }\n" + + "}"; + + // Compare the JSON strings + Assert.assertEquals(JsonParser.parseString(providedJson), JsonParser.parseString(listJson)); + } + + private ListRequest createListRequest() { + ListRequest list = new ListRequest(); + list.setName("Malicious IPs"); + list.setDescription("We block these IPs from withdrawing funds. Please be careful."); + list.setColor(ListColor.RED); + list.setDefaultItemArchivationTime(2592000); + list.primaryField("device.fingerprint"); + list.secondaryField("ip.value"); + return list; + } + + @Test + public void compareListRequestJson() { + ListRequest list = createListRequest(); + + // Convert list request object to JSON + CastleGsonModel gson = new CastleGsonModel(); + String listJson = gson.getGson().toJson(list); + + // Provided JSON + String providedJson = "{\n" + + " \"name\": \"Malicious IPs\",\n" + + " \"description\": \"We block these IPs from withdrawing funds. Please be careful.\",\n" + + " \"color\": \"$red\",\n" + + " \"default_item_archivation_time\": 2592000,\n" + + " \"primary_field\": \"device.fingerprint\",\n" + + " \"secondary_field\": \"ip.value\"\n" + + "}"; + + // Compare the JSON strings + Assert.assertEquals(JsonParser.parseString(providedJson), JsonParser.parseString(listJson)); + } + + private ListRequest createListResponse() { + ListResponse list = new ListResponse(); + list.setName("Malicious IPs"); + list.setDescription("We block these IPs from withdrawing funds. Please be careful."); + list.setColor(ListColor.RED); + list.setDefaultItemArchivationTime(2592000); + list.primaryField("device.fingerprint"); + list.secondaryField("ip.value"); + list.setId("2ee938c8-24c2-4c26-9d25-19511dd75029"); + list.setArchivedAt(OffsetDateTime.parse("2021-09-27T16:46:38.313Z")); + list.setCreatedAt(OffsetDateTime.parse("2021-09-27T16:46:38.313Z")); + + return list; + } + + @Test + public void compareListResponseJson() { + ListRequest list = createListResponse(); + + // Convert list response object to JSON + CastleGsonModel gson = new CastleGsonModel(); + String listJson = gson.getGson().toJson(list); + + // Provided JSON + String providedJson = "{\n" + + " \"name\": \"Malicious IPs\",\n" + + " \"description\": \"We block these IPs from withdrawing funds. Please be careful.\",\n" + + " \"color\": \"$red\",\n" + + " \"default_item_archivation_time\": 2592000,\n" + + " \"id\": \"2ee938c8-24c2-4c26-9d25-19511dd75029\",\n" + + " \"primary_field\": \"device.fingerprint\",\n" + + " \"secondary_field\": \"ip.value\",\n" + + " \"archived_at\": \"2021-09-27T16:46:38.313Z\",\n" + + " \"created_at\": \"2021-09-27T16:46:38.313Z\"\n" + + "}"; + + // Compare the JSON strings + Assert.assertEquals(JsonParser.parseString(providedJson), JsonParser.parseString(listJson)); + } +} diff --git a/src/test/java/io/castle/client/internal/utils/CastleContextBuilderTest.java b/src/test/java/io/castle/client/internal/utils/CastleContextBuilderTest.java index 4dd345e..34c5a62 100644 --- a/src/test/java/io/castle/client/internal/utils/CastleContextBuilderTest.java +++ b/src/test/java/io/castle/client/internal/utils/CastleContextBuilderTest.java @@ -307,25 +307,25 @@ public void withCustomIPHeaders() throws CastleSdkConfigurationException, JSONEx Assertions.assertThat(context.getIp()).isEqualTo(standardContext.getIp()); } - private String valueControlCache = "max-age=0"; - private String keyControlCache = "Cache-Control"; - private String userAgent = "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0"; - private String ip = "8.8.8.8"; - private String userAgentHeader = "User-Agent"; - private String customClientIdHeader = "X-Castle-Client-Id"; - private String acceptHeader = "Accept"; - private String accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; - private String acceptLanguageHeader = "Accept-Language"; - private String acceptLanguage = "en-US,en;q=0.5"; - private String connectionHeader = "Connection"; - private String connection = "keep-alive"; - private String refererHeader = "Referer"; - private String referer = "http://localhost:8080/"; - private String headerHost = "Host"; - private String hostValue = "localhost:8080"; - private String acceptEncodingHeader = "Accept-Encoding"; - private String acceptEncoding = "gzip, deflate"; - private String cgiSpecHeaderName = "REMOTE_ADDR"; + private final String valueControlCache = "max-age=0"; + private final String keyControlCache = "Cache-Control"; + private final String userAgent = "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0"; + private final String ip = "8.8.8.8"; + private final String userAgentHeader = "User-Agent"; + private final String customClientIdHeader = "X-Castle-Client-Id"; + private final String acceptHeader = "Accept"; + private final String accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; + private final String acceptLanguageHeader = "Accept-Language"; + private final String acceptLanguage = "en-US,en;q=0.5"; + private final String connectionHeader = "Connection"; + private final String connection = "keep-alive"; + private final String refererHeader = "Referer"; + private final String referer = "http://localhost:8080/"; + private final String headerHost = "Host"; + private final String hostValue = "localhost:8080"; + private final String acceptEncodingHeader = "Accept-Encoding"; + private final String acceptEncoding = "gzip, deflate"; + private final String cgiSpecHeaderName = "REMOTE_ADDR"; public MockHttpServletRequest getStandardRequestMock() { MockHttpServletRequest request = new MockHttpServletRequest(); diff --git a/src/test/java/io/castle/client/model/CastleContextTest.java b/src/test/java/io/castle/client/model/CastleContextTest.java index a3bef5f..43cfeba 100644 --- a/src/test/java/io/castle/client/model/CastleContextTest.java +++ b/src/test/java/io/castle/client/model/CastleContextTest.java @@ -43,8 +43,7 @@ public void booleanContextValues() throws JSONException { //Then generated json match the api contract String expectedJson = "{\"active\":true," + - "\"client_id\":true," + - "" + SDKVersion.getLibraryString() +"," + + "\"client_id\":true," + SDKVersion.getLibraryString() +"," + "\"user_agent\":true}"; JSONAssert.assertEquals(expectedJson, contextJson, true); @@ -126,8 +125,7 @@ public void completeContextJsonSpec() throws JSONException { "\"page\":{\"path\":\"p_path\",\"referrer\":\"p_referrer\",\"search\":\"p_search\",\"title\":\"p_title\",\"url\":\"p_url\"}," + "\"referrer\":{\"id\":\"r_id\",\"type\":\"r_type\"}," + "\"headers\":{\"key1\":\"value1\",\"key2\":\"value2\"}," + - "\"ip\":\"ip\"," + - "" + SDKVersion.getLibraryString() +"," + + "\"ip\":\"ip\"," + SDKVersion.getLibraryString() +"," + "\"locale\":\"locale\"," + "\"location\":{\"city\":\"l_city\",\"country\":\"l_country\",\"latitude\":10,\"longitude\":10,\"speed\":0}," + "\"network\":{\"bluetooth\":true,\"cellular\":true,\"carrier\":\"n_carrier\",\"wifi\":true}," + diff --git a/src/test/java/io/castle/client/utils/DeviceUtils.java b/src/test/java/io/castle/client/utils/DeviceUtils.java index a20eaf1..05a3d24 100644 --- a/src/test/java/io/castle/client/utils/DeviceUtils.java +++ b/src/test/java/io/castle/client/utils/DeviceUtils.java @@ -6,6 +6,7 @@ import io.castle.client.model.DeviceUserAgent; import java.util.Arrays; +import java.util.List; public class DeviceUtils { @@ -62,7 +63,7 @@ public static CastleUserDevice createExpectedDevice() { public static CastleUserDevices createExpectedDevices() { CastleUserDevices devices = new CastleUserDevices(); - devices.setDevices(Arrays.asList(createExpectedDevice())); + devices.setDevices(List.of(createExpectedDevice())); return devices; } diff --git a/src/test/java/io/castle/client/utils/SDKVersion.java b/src/test/java/io/castle/client/utils/SDKVersion.java index 5b21ce2..15594a2 100644 --- a/src/test/java/io/castle/client/utils/SDKVersion.java +++ b/src/test/java/io/castle/client/utils/SDKVersion.java @@ -8,9 +8,9 @@ public class SDKVersion { - private static String libraryString = "\"library\":{\"name\":\"castle-java\",\"version\":\"" + getSDKVersion() + "\",\"platform\":\"" + getJavaPlatform() + "\",\"platform_version\":\"" + getJavaVersion() + "\"}"; + private static final String libraryString = "\"library\":{\"name\":\"castle-java\",\"version\":\"" + getSDKVersion() + "\",\"platform\":\"" + getJavaPlatform() + "\",\"platform_version\":\"" + getJavaVersion() + "\"}"; - private static String version = getSDKVersion(); + private static final String version = getSDKVersion(); public static String getLibraryString() { return libraryString;