* | :heavy_minus_sign: | The maximum number of items that are returned. | 20 |
+
+### Response
+
+**[ListRolesResponse](../../models/operations/ListRolesResponse.md)**
+
+### Errors
+
+| Error Type | Status Code | Content Type |
+| --------------------------------- | --------------------------------- | --------------------------------- |
+| models/errors/Error400 | 400 | application/json |
+| models/errors/Error401 | 401 | application/json |
+| models/errors/Error403 | 403 | application/json |
+| models/errors/Error404 | 404 | application/json |
+| models/errors/Error405 | 405 | application/json |
+| models/errors/Error409 | 409 | application/json |
+| models/errors/HTTPValidationError | 422 | application/json |
+| models/errors/Error425 | 425 | application/json |
+| models/errors/Error429 | 429 | application/json |
+| models/errors/Error500 | 500 | application/json |
+| models/errors/Error502 | 502 | application/json |
+| models/errors/Error504 | 504 | application/json |
+| models/errors/APIException | 4XX, 5XX | \*/\* |
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
index fa2471cc..43b6a196 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,4 +1,4 @@
groupId=com.gr4vy
artifactId=sdk
-version=2.18.11
+version=2.18.12
org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g
diff --git a/src/main/java/com/gr4vy/sdk/AsyncGr4vy.java b/src/main/java/com/gr4vy/sdk/AsyncGr4vy.java
index 59bfd5b6..653d7d2f 100644
--- a/src/main/java/com/gr4vy/sdk/AsyncGr4vy.java
+++ b/src/main/java/com/gr4vy/sdk/AsyncGr4vy.java
@@ -43,6 +43,8 @@ public class AsyncGr4vy {
private final AsyncCheckoutSessions checkoutSessions;
+ private final AsyncRoles roles;
+
private final AsyncMerchantAccounts merchantAccounts;
private final AsyncThreeDsScenarios threeDsScenarios;
@@ -115,6 +117,10 @@ public AsyncCheckoutSessions checkoutSessions() {
return checkoutSessions;
}
+ public AsyncRoles roles() {
+ return roles;
+ }
+
public AsyncMerchantAccounts merchantAccounts() {
return merchantAccounts;
}
@@ -153,6 +159,7 @@ public AsyncPaymentLinks paymentLinks() {
this.reports = new AsyncReports(syncSDK.reports(), sdkConfiguration);
this.reportExecutions = new AsyncReportExecutions(syncSDK.reportExecutions(), sdkConfiguration);
this.checkoutSessions = new AsyncCheckoutSessions(syncSDK.checkoutSessions(), sdkConfiguration);
+ this.roles = new AsyncRoles(syncSDK.roles(), sdkConfiguration);
this.merchantAccounts = new AsyncMerchantAccounts(syncSDK.merchantAccounts(), sdkConfiguration);
this.threeDsScenarios = new AsyncThreeDsScenarios(syncSDK.threeDsScenarios(), sdkConfiguration);
this.payouts = new AsyncPayouts(syncSDK.payouts(), sdkConfiguration);
diff --git a/src/main/java/com/gr4vy/sdk/AsyncRoles.java b/src/main/java/com/gr4vy/sdk/AsyncRoles.java
new file mode 100644
index 00000000..86d3990f
--- /dev/null
+++ b/src/main/java/com/gr4vy/sdk/AsyncRoles.java
@@ -0,0 +1,90 @@
+/*
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
+ */
+package com.gr4vy.sdk;
+
+import static com.gr4vy.sdk.operations.Operations.AsyncRequestOperation;
+
+import com.gr4vy.sdk.models.operations.ListRolesRequest;
+import com.gr4vy.sdk.models.operations.async.ListRolesRequestBuilder;
+import com.gr4vy.sdk.models.operations.async.ListRolesResponse;
+import com.gr4vy.sdk.operations.ListRoles;
+import com.gr4vy.sdk.utils.Headers;
+import com.gr4vy.sdk.utils.Options;
+import java.lang.Long;
+import java.lang.String;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import org.openapitools.jackson.nullable.JsonNullable;
+
+
+public class AsyncRoles {
+ private static final Headers _headers = Headers.EMPTY;
+ private final SDKConfiguration sdkConfiguration;
+ private final Roles syncSDK;
+
+ AsyncRoles(Roles syncSDK, SDKConfiguration sdkConfiguration) {
+ this.sdkConfiguration = sdkConfiguration;
+ this.syncSDK = syncSDK;
+ }
+
+ /**
+ * Switches to the sync SDK.
+ *
+ * @return The sync SDK
+ */
+ public Roles sync() {
+ return syncSDK;
+ }
+
+
+ /**
+ * List all roles
+ *
+ * List all roles available in the instance.
+ *
+ * @return The async call builder
+ */
+ public ListRolesRequestBuilder list() {
+ return new ListRolesRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * List all roles
+ *
+ *
List all roles available in the instance.
+ *
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture listDirect() {
+ return list(JsonNullable.undefined(), Optional.empty(), Optional.empty());
+ }
+
+ /**
+ * List all roles
+ *
+ * List all roles available in the instance.
+ *
+ * @param cursor A pointer to the page of results to return.
+ * @param limit The maximum number of items that are returned.
+ * @param options additional options
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture list(
+ JsonNullable cursor, Optional limit,
+ Optional options) {
+ ListRolesRequest request =
+ ListRolesRequest
+ .builder()
+ .cursor(cursor)
+ .limit(limit)
+ .build();
+ AsyncRequestOperation operation
+ = new ListRoles.Async(
+ sdkConfiguration, options, sdkConfiguration.retryScheduler(),
+ _headers);
+ return operation.doRequest(request)
+ .thenCompose(operation::handleResponse);
+ }
+
+}
diff --git a/src/main/java/com/gr4vy/sdk/Gr4vy.java b/src/main/java/com/gr4vy/sdk/Gr4vy.java
index 8f82bd1d..bf7c357f 100644
--- a/src/main/java/com/gr4vy/sdk/Gr4vy.java
+++ b/src/main/java/com/gr4vy/sdk/Gr4vy.java
@@ -100,6 +100,9 @@ public String server() {
private final CheckoutSessions checkoutSessions;
+ private final Roles roles;
+
+
private final MerchantAccounts merchantAccounts;
@@ -192,6 +195,11 @@ public CheckoutSessions checkoutSessions() {
}
+ public Roles roles() {
+ return roles;
+ }
+
+
public MerchantAccounts merchantAccounts() {
return merchantAccounts;
}
@@ -397,6 +405,7 @@ private Gr4vy(SDKConfiguration sdkConfiguration) {
this.reports = new Reports(sdkConfiguration);
this.reportExecutions = new ReportExecutions(sdkConfiguration);
this.checkoutSessions = new CheckoutSessions(sdkConfiguration);
+ this.roles = new Roles(sdkConfiguration);
this.merchantAccounts = new MerchantAccounts(sdkConfiguration);
this.threeDsScenarios = new ThreeDsScenarios(sdkConfiguration);
this.payouts = new Payouts(sdkConfiguration);
diff --git a/src/main/java/com/gr4vy/sdk/Roles.java b/src/main/java/com/gr4vy/sdk/Roles.java
new file mode 100644
index 00000000..b50475cc
--- /dev/null
+++ b/src/main/java/com/gr4vy/sdk/Roles.java
@@ -0,0 +1,87 @@
+/*
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
+ */
+package com.gr4vy.sdk;
+
+import static com.gr4vy.sdk.operations.Operations.RequestOperation;
+
+import com.gr4vy.sdk.models.operations.ListRolesRequest;
+import com.gr4vy.sdk.models.operations.ListRolesRequestBuilder;
+import com.gr4vy.sdk.models.operations.ListRolesResponse;
+import com.gr4vy.sdk.operations.ListRoles;
+import com.gr4vy.sdk.utils.Headers;
+import com.gr4vy.sdk.utils.Options;
+import java.lang.Long;
+import java.lang.String;
+import java.util.Optional;
+import org.openapitools.jackson.nullable.JsonNullable;
+
+
+public class Roles {
+ private static final Headers _headers = Headers.EMPTY;
+ private final SDKConfiguration sdkConfiguration;
+ private final AsyncRoles asyncSDK;
+
+ Roles(SDKConfiguration sdkConfiguration) {
+ this.sdkConfiguration = sdkConfiguration;
+ this.asyncSDK = new AsyncRoles(this, sdkConfiguration);
+ }
+
+ /**
+ * Switches to the async SDK.
+ *
+ * @return The async SDK
+ */
+ public AsyncRoles async() {
+ return asyncSDK;
+ }
+
+ /**
+ * List all roles
+ *
+ * List all roles available in the instance.
+ *
+ * @return The call builder
+ */
+ public ListRolesRequestBuilder list() {
+ return new ListRolesRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * List all roles
+ *
+ *
List all roles available in the instance.
+ *
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public ListRolesResponse listDirect() {
+ return list(JsonNullable.undefined(), Optional.empty(), Optional.empty());
+ }
+
+ /**
+ * List all roles
+ *
+ *
List all roles available in the instance.
+ *
+ * @param cursor A pointer to the page of results to return.
+ * @param limit The maximum number of items that are returned.
+ * @param options additional options
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public ListRolesResponse list(
+ JsonNullable cursor, Optional limit,
+ Optional options) {
+ ListRolesRequest request =
+ ListRolesRequest
+ .builder()
+ .cursor(cursor)
+ .limit(limit)
+ .build();
+ RequestOperation operation
+ = new ListRoles.Sync(sdkConfiguration, options, _headers);
+ return operation.handleResponse(operation.doRequest(request));
+ }
+
+}
diff --git a/src/main/java/com/gr4vy/sdk/SDKConfiguration.java b/src/main/java/com/gr4vy/sdk/SDKConfiguration.java
index 7246a2b9..75909a79 100644
--- a/src/main/java/com/gr4vy/sdk/SDKConfiguration.java
+++ b/src/main/java/com/gr4vy/sdk/SDKConfiguration.java
@@ -22,7 +22,7 @@ public class SDKConfiguration {
private static final String LANGUAGE = "java";
public static final String OPENAPI_DOC_VERSION = "1.0.0";
- public static final String SDK_VERSION = "2.18.11";
+ public static final String SDK_VERSION = "2.18.12";
public static final String GEN_VERSION = "2.928.0";
private static final String BASE_PACKAGE = "com.gr4vy.sdk";
public static final String USER_AGENT =
diff --git a/src/main/java/com/gr4vy/sdk/models/components/CollectionRole.java b/src/main/java/com/gr4vy/sdk/models/components/CollectionRole.java
new file mode 100644
index 00000000..4137e86e
--- /dev/null
+++ b/src/main/java/com/gr4vy/sdk/models/components/CollectionRole.java
@@ -0,0 +1,304 @@
+/*
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
+ */
+package com.gr4vy.sdk.models.components;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.gr4vy.sdk.utils.LazySingletonValue;
+import com.gr4vy.sdk.utils.Utils;
+import java.lang.Long;
+import java.lang.Override;
+import java.lang.String;
+import java.util.List;
+import java.util.Optional;
+import org.openapitools.jackson.nullable.JsonNullable;
+
+
+public class CollectionRole {
+ /**
+ * A list of items returned for this request.
+ */
+ @JsonProperty("items")
+ private List items;
+
+ /**
+ * The number of items for this page.
+ */
+ @JsonInclude(Include.NON_ABSENT)
+ @JsonProperty("limit")
+ private Optional limit;
+
+ /**
+ * The cursor pointing at the next page of items.
+ */
+ @JsonInclude(Include.NON_ABSENT)
+ @JsonProperty("next_cursor")
+ private JsonNullable nextCursor;
+
+ /**
+ * The cursor pointing at the previous page of items.
+ */
+ @JsonInclude(Include.NON_ABSENT)
+ @JsonProperty("previous_cursor")
+ private JsonNullable previousCursor;
+
+ @JsonCreator
+ public CollectionRole(
+ @JsonProperty("items") List items,
+ @JsonProperty("limit") Optional limit,
+ @JsonProperty("next_cursor") JsonNullable nextCursor,
+ @JsonProperty("previous_cursor") JsonNullable previousCursor) {
+ Utils.checkNotNull(items, "items");
+ Utils.checkNotNull(limit, "limit");
+ Utils.checkNotNull(nextCursor, "nextCursor");
+ Utils.checkNotNull(previousCursor, "previousCursor");
+ this.items = items;
+ this.limit = limit;
+ this.nextCursor = nextCursor;
+ this.previousCursor = previousCursor;
+ }
+
+ public CollectionRole(
+ List items) {
+ this(items, Optional.empty(), JsonNullable.undefined(),
+ JsonNullable.undefined());
+ }
+
+ /**
+ * A list of items returned for this request.
+ */
+ @JsonIgnore
+ public List items() {
+ return items;
+ }
+
+ /**
+ * The number of items for this page.
+ */
+ @JsonIgnore
+ public Optional limit() {
+ return limit;
+ }
+
+ /**
+ * The cursor pointing at the next page of items.
+ */
+ @JsonIgnore
+ public JsonNullable nextCursor() {
+ return nextCursor;
+ }
+
+ /**
+ * The cursor pointing at the previous page of items.
+ */
+ @JsonIgnore
+ public JsonNullable previousCursor() {
+ return previousCursor;
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+
+ /**
+ * A list of items returned for this request.
+ */
+ public CollectionRole withItems(List items) {
+ Utils.checkNotNull(items, "items");
+ this.items = items;
+ return this;
+ }
+
+ /**
+ * The number of items for this page.
+ */
+ public CollectionRole withLimit(long limit) {
+ Utils.checkNotNull(limit, "limit");
+ this.limit = Optional.ofNullable(limit);
+ return this;
+ }
+
+
+ /**
+ * The number of items for this page.
+ */
+ public CollectionRole withLimit(Optional limit) {
+ Utils.checkNotNull(limit, "limit");
+ this.limit = limit;
+ return this;
+ }
+
+ /**
+ * The cursor pointing at the next page of items.
+ */
+ public CollectionRole withNextCursor(String nextCursor) {
+ Utils.checkNotNull(nextCursor, "nextCursor");
+ this.nextCursor = JsonNullable.of(nextCursor);
+ return this;
+ }
+
+ /**
+ * The cursor pointing at the next page of items.
+ */
+ public CollectionRole withNextCursor(JsonNullable nextCursor) {
+ Utils.checkNotNull(nextCursor, "nextCursor");
+ this.nextCursor = nextCursor;
+ return this;
+ }
+
+ /**
+ * The cursor pointing at the previous page of items.
+ */
+ public CollectionRole withPreviousCursor(String previousCursor) {
+ Utils.checkNotNull(previousCursor, "previousCursor");
+ this.previousCursor = JsonNullable.of(previousCursor);
+ return this;
+ }
+
+ /**
+ * The cursor pointing at the previous page of items.
+ */
+ public CollectionRole withPreviousCursor(JsonNullable previousCursor) {
+ Utils.checkNotNull(previousCursor, "previousCursor");
+ this.previousCursor = previousCursor;
+ return this;
+ }
+
+ @Override
+ public boolean equals(java.lang.Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ CollectionRole other = (CollectionRole) o;
+ return
+ Utils.enhancedDeepEquals(this.items, other.items) &&
+ Utils.enhancedDeepEquals(this.limit, other.limit) &&
+ Utils.enhancedDeepEquals(this.nextCursor, other.nextCursor) &&
+ Utils.enhancedDeepEquals(this.previousCursor, other.previousCursor);
+ }
+
+ @Override
+ public int hashCode() {
+ return Utils.enhancedHash(
+ items, limit, nextCursor,
+ previousCursor);
+ }
+
+ @Override
+ public String toString() {
+ return Utils.toString(CollectionRole.class,
+ "items", items,
+ "limit", limit,
+ "nextCursor", nextCursor,
+ "previousCursor", previousCursor);
+ }
+
+ @SuppressWarnings("UnusedReturnValue")
+ public final static class Builder {
+
+ private List items;
+
+ private Optional limit;
+
+ private JsonNullable nextCursor = JsonNullable.undefined();
+
+ private JsonNullable previousCursor = JsonNullable.undefined();
+
+ private Builder() {
+ // force use of static builder() method
+ }
+
+
+ /**
+ * A list of items returned for this request.
+ */
+ public Builder items(List items) {
+ Utils.checkNotNull(items, "items");
+ this.items = items;
+ return this;
+ }
+
+
+ /**
+ * The number of items for this page.
+ */
+ public Builder limit(long limit) {
+ Utils.checkNotNull(limit, "limit");
+ this.limit = Optional.ofNullable(limit);
+ return this;
+ }
+
+ /**
+ * The number of items for this page.
+ */
+ public Builder limit(Optional limit) {
+ Utils.checkNotNull(limit, "limit");
+ this.limit = limit;
+ return this;
+ }
+
+
+ /**
+ * The cursor pointing at the next page of items.
+ */
+ public Builder nextCursor(String nextCursor) {
+ Utils.checkNotNull(nextCursor, "nextCursor");
+ this.nextCursor = JsonNullable.of(nextCursor);
+ return this;
+ }
+
+ /**
+ * The cursor pointing at the next page of items.
+ */
+ public Builder nextCursor(JsonNullable nextCursor) {
+ Utils.checkNotNull(nextCursor, "nextCursor");
+ this.nextCursor = nextCursor;
+ return this;
+ }
+
+
+ /**
+ * The cursor pointing at the previous page of items.
+ */
+ public Builder previousCursor(String previousCursor) {
+ Utils.checkNotNull(previousCursor, "previousCursor");
+ this.previousCursor = JsonNullable.of(previousCursor);
+ return this;
+ }
+
+ /**
+ * The cursor pointing at the previous page of items.
+ */
+ public Builder previousCursor(JsonNullable previousCursor) {
+ Utils.checkNotNull(previousCursor, "previousCursor");
+ this.previousCursor = previousCursor;
+ return this;
+ }
+
+ public CollectionRole build() {
+ if (limit == null) {
+ limit = _SINGLETON_VALUE_Limit.value();
+ }
+
+ return new CollectionRole(
+ items, limit, nextCursor,
+ previousCursor);
+ }
+
+
+ private static final LazySingletonValue> _SINGLETON_VALUE_Limit =
+ new LazySingletonValue<>(
+ "limit",
+ "20",
+ new TypeReference>() {});
+ }
+}
diff --git a/src/main/java/com/gr4vy/sdk/models/components/PermissionSet.java b/src/main/java/com/gr4vy/sdk/models/components/PermissionSet.java
index 415f8908..67442075 100644
--- a/src/main/java/com/gr4vy/sdk/models/components/PermissionSet.java
+++ b/src/main/java/com/gr4vy/sdk/models/components/PermissionSet.java
@@ -11,9 +11,15 @@
import java.lang.String;
import java.util.List;
-
+/**
+ * PermissionSet
+ *
+ * The permissions granted by a role.
+ */
public class PermissionSet {
-
+ /**
+ * The scopes granted by this role.
+ */
@JsonProperty("allow")
private List allow;
@@ -24,6 +30,9 @@ public PermissionSet(
this.allow = allow;
}
+ /**
+ * The scopes granted by this role.
+ */
@JsonIgnore
public List allow() {
return allow;
@@ -34,6 +43,9 @@ public static Builder builder() {
}
+ /**
+ * The scopes granted by this role.
+ */
public PermissionSet withAllow(List allow) {
Utils.checkNotNull(allow, "allow");
this.allow = allow;
@@ -75,6 +87,9 @@ private Builder() {
}
+ /**
+ * The scopes granted by this role.
+ */
public Builder allow(List allow) {
Utils.checkNotNull(allow, "allow");
this.allow = allow;
diff --git a/src/main/java/com/gr4vy/sdk/models/components/Role.java b/src/main/java/com/gr4vy/sdk/models/components/Role.java
index f5e86ced..02fb2685 100644
--- a/src/main/java/com/gr4vy/sdk/models/components/Role.java
+++ b/src/main/java/com/gr4vy/sdk/models/components/Role.java
@@ -19,16 +19,22 @@
public class Role {
-
+ /**
+ * Always `role`.
+ */
@JsonInclude(Include.NON_ABSENT)
@JsonProperty("type")
private Optional type;
-
+ /**
+ * The unique ID for the role.
+ */
@JsonProperty("id")
private String id;
-
+ /**
+ * The human-readable name of the role.
+ */
@JsonProperty("name")
private String name;
@@ -38,11 +44,15 @@ public class Role {
@JsonProperty("slug")
private String slug;
-
+ /**
+ * A description of the access this role grants.
+ */
@JsonProperty("description")
private String description;
-
+ /**
+ * The permissions granted by a role.
+ */
@JsonProperty("permissions")
private PermissionSet permissions;
@@ -93,16 +103,25 @@ public Role(
this.isStandaloneAssignable = isStandaloneAssignable;
}
+ /**
+ * Always `role`.
+ */
@JsonIgnore
public Optional type() {
return type;
}
+ /**
+ * The unique ID for the role.
+ */
@JsonIgnore
public String id() {
return id;
}
+ /**
+ * The human-readable name of the role.
+ */
@JsonIgnore
public String name() {
return name;
@@ -116,11 +135,17 @@ public String slug() {
return slug;
}
+ /**
+ * A description of the access this role grants.
+ */
@JsonIgnore
public String description() {
return description;
}
+ /**
+ * The permissions granted by a role.
+ */
@JsonIgnore
public PermissionSet permissions() {
return permissions;
@@ -155,12 +180,18 @@ public static Builder builder() {
}
+ /**
+ * The unique ID for the role.
+ */
public Role withId(String id) {
Utils.checkNotNull(id, "id");
this.id = id;
return this;
}
+ /**
+ * The human-readable name of the role.
+ */
public Role withName(String name) {
Utils.checkNotNull(name, "name");
this.name = name;
@@ -176,12 +207,18 @@ public Role withSlug(String slug) {
return this;
}
+ /**
+ * A description of the access this role grants.
+ */
public Role withDescription(String description) {
Utils.checkNotNull(description, "description");
this.description = description;
return this;
}
+ /**
+ * The permissions granted by a role.
+ */
public Role withPermissions(PermissionSet permissions) {
Utils.checkNotNull(permissions, "permissions");
this.permissions = permissions;
@@ -282,6 +319,9 @@ private Builder() {
}
+ /**
+ * The unique ID for the role.
+ */
public Builder id(String id) {
Utils.checkNotNull(id, "id");
this.id = id;
@@ -289,6 +329,9 @@ public Builder id(String id) {
}
+ /**
+ * The human-readable name of the role.
+ */
public Builder name(String name) {
Utils.checkNotNull(name, "name");
this.name = name;
@@ -306,6 +349,9 @@ public Builder slug(String slug) {
}
+ /**
+ * A description of the access this role grants.
+ */
public Builder description(String description) {
Utils.checkNotNull(description, "description");
this.description = description;
@@ -313,6 +359,9 @@ public Builder description(String description) {
}
+ /**
+ * The permissions granted by a role.
+ */
public Builder permissions(PermissionSet permissions) {
Utils.checkNotNull(permissions, "permissions");
this.permissions = permissions;
diff --git a/src/main/java/com/gr4vy/sdk/models/operations/ListRolesRequest.java b/src/main/java/com/gr4vy/sdk/models/operations/ListRolesRequest.java
new file mode 100644
index 00000000..089b3c51
--- /dev/null
+++ b/src/main/java/com/gr4vy/sdk/models/operations/ListRolesRequest.java
@@ -0,0 +1,196 @@
+/*
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
+ */
+package com.gr4vy.sdk.models.operations;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.gr4vy.sdk.utils.LazySingletonValue;
+import com.gr4vy.sdk.utils.SpeakeasyMetadata;
+import com.gr4vy.sdk.utils.Utils;
+import java.lang.Long;
+import java.lang.Override;
+import java.lang.String;
+import java.util.Optional;
+import org.openapitools.jackson.nullable.JsonNullable;
+
+
+public class ListRolesRequest {
+ /**
+ * A pointer to the page of results to return.
+ */
+ @SpeakeasyMetadata("queryParam:style=form,explode=true,name=cursor")
+ private JsonNullable cursor;
+
+ /**
+ * The maximum number of items that are returned.
+ */
+ @SpeakeasyMetadata("queryParam:style=form,explode=true,name=limit")
+ private Optional limit;
+
+ @JsonCreator
+ public ListRolesRequest(
+ JsonNullable cursor,
+ Optional limit) {
+ Utils.checkNotNull(cursor, "cursor");
+ Utils.checkNotNull(limit, "limit");
+ this.cursor = cursor;
+ this.limit = limit;
+ }
+
+ public ListRolesRequest() {
+ this(JsonNullable.undefined(), Optional.empty());
+ }
+
+ /**
+ * A pointer to the page of results to return.
+ */
+ @JsonIgnore
+ public JsonNullable cursor() {
+ return cursor;
+ }
+
+ /**
+ * The maximum number of items that are returned.
+ */
+ @JsonIgnore
+ public Optional limit() {
+ return limit;
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+
+ /**
+ * A pointer to the page of results to return.
+ */
+ public ListRolesRequest withCursor(String cursor) {
+ Utils.checkNotNull(cursor, "cursor");
+ this.cursor = JsonNullable.of(cursor);
+ return this;
+ }
+
+ /**
+ * A pointer to the page of results to return.
+ */
+ public ListRolesRequest withCursor(JsonNullable cursor) {
+ Utils.checkNotNull(cursor, "cursor");
+ this.cursor = cursor;
+ return this;
+ }
+
+ /**
+ * The maximum number of items that are returned.
+ */
+ public ListRolesRequest withLimit(long limit) {
+ Utils.checkNotNull(limit, "limit");
+ this.limit = Optional.ofNullable(limit);
+ return this;
+ }
+
+
+ /**
+ * The maximum number of items that are returned.
+ */
+ public ListRolesRequest withLimit(Optional limit) {
+ Utils.checkNotNull(limit, "limit");
+ this.limit = limit;
+ return this;
+ }
+
+ @Override
+ public boolean equals(java.lang.Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ ListRolesRequest other = (ListRolesRequest) o;
+ return
+ Utils.enhancedDeepEquals(this.cursor, other.cursor) &&
+ Utils.enhancedDeepEquals(this.limit, other.limit);
+ }
+
+ @Override
+ public int hashCode() {
+ return Utils.enhancedHash(
+ cursor, limit);
+ }
+
+ @Override
+ public String toString() {
+ return Utils.toString(ListRolesRequest.class,
+ "cursor", cursor,
+ "limit", limit);
+ }
+
+ @SuppressWarnings("UnusedReturnValue")
+ public final static class Builder {
+
+ private JsonNullable cursor = JsonNullable.undefined();
+
+ private Optional limit;
+
+ private Builder() {
+ // force use of static builder() method
+ }
+
+
+ /**
+ * A pointer to the page of results to return.
+ */
+ public Builder cursor(String cursor) {
+ Utils.checkNotNull(cursor, "cursor");
+ this.cursor = JsonNullable.of(cursor);
+ return this;
+ }
+
+ /**
+ * A pointer to the page of results to return.
+ */
+ public Builder cursor(JsonNullable cursor) {
+ Utils.checkNotNull(cursor, "cursor");
+ this.cursor = cursor;
+ return this;
+ }
+
+
+ /**
+ * The maximum number of items that are returned.
+ */
+ public Builder limit(long limit) {
+ Utils.checkNotNull(limit, "limit");
+ this.limit = Optional.ofNullable(limit);
+ return this;
+ }
+
+ /**
+ * The maximum number of items that are returned.
+ */
+ public Builder limit(Optional limit) {
+ Utils.checkNotNull(limit, "limit");
+ this.limit = limit;
+ return this;
+ }
+
+ public ListRolesRequest build() {
+ if (limit == null) {
+ limit = _SINGLETON_VALUE_Limit.value();
+ }
+
+ return new ListRolesRequest(
+ cursor, limit);
+ }
+
+
+ private static final LazySingletonValue> _SINGLETON_VALUE_Limit =
+ new LazySingletonValue<>(
+ "limit",
+ "20",
+ new TypeReference>() {});
+ }
+}
diff --git a/src/main/java/com/gr4vy/sdk/models/operations/ListRolesRequestBuilder.java b/src/main/java/com/gr4vy/sdk/models/operations/ListRolesRequestBuilder.java
new file mode 100644
index 00000000..a04a9294
--- /dev/null
+++ b/src/main/java/com/gr4vy/sdk/models/operations/ListRolesRequestBuilder.java
@@ -0,0 +1,152 @@
+/*
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
+ */
+package com.gr4vy.sdk.models.operations;
+
+import static com.gr4vy.sdk.operations.Operations.RequestOperation;
+import static com.gr4vy.sdk.utils.Exceptions.unchecked;
+import static com.gr4vy.sdk.utils.Utils.transform;
+import static com.gr4vy.sdk.utils.Utils.toStream;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.gr4vy.sdk.SDKConfiguration;
+import com.gr4vy.sdk.operations.ListRoles;
+import com.gr4vy.sdk.utils.Headers;
+import com.gr4vy.sdk.utils.LazySingletonValue;
+import com.gr4vy.sdk.utils.Options;
+import com.gr4vy.sdk.utils.RetryConfig;
+import com.gr4vy.sdk.utils.Utils;
+import com.gr4vy.sdk.utils.pagination.CursorTracker;
+import com.gr4vy.sdk.utils.pagination.Paginator;
+import java.io.InputStream;
+import java.lang.Iterable;
+import java.lang.Long;
+import java.lang.String;
+import java.net.http.HttpResponse;
+import java.util.Iterator;
+import java.util.Optional;
+import java.util.stream.Stream;
+import org.openapitools.jackson.nullable.JsonNullable;
+
+public class ListRolesRequestBuilder {
+
+ private JsonNullable cursor = JsonNullable.undefined();
+ private Optional limit = Utils.readDefaultOrConstValue(
+ "limit",
+ "20",
+ new TypeReference>() {});
+ private Optional retryConfig = Optional.empty();
+ private final SDKConfiguration sdkConfiguration;
+ private final Headers _headers = new Headers();
+
+ public ListRolesRequestBuilder(SDKConfiguration sdkConfiguration) {
+ this.sdkConfiguration = sdkConfiguration;
+ }
+
+ public ListRolesRequestBuilder cursor(String cursor) {
+ Utils.checkNotNull(cursor, "cursor");
+ this.cursor = JsonNullable.of(cursor);
+ return this;
+ }
+
+ public ListRolesRequestBuilder cursor(JsonNullable cursor) {
+ Utils.checkNotNull(cursor, "cursor");
+ this.cursor = cursor;
+ return this;
+ }
+
+ public ListRolesRequestBuilder limit(long limit) {
+ Utils.checkNotNull(limit, "limit");
+ this.limit = Optional.of(limit);
+ return this;
+ }
+
+ public ListRolesRequestBuilder limit(Optional limit) {
+ Utils.checkNotNull(limit, "limit");
+ this.limit = limit;
+ return this;
+ }
+
+ public ListRolesRequestBuilder retryConfig(RetryConfig retryConfig) {
+ Utils.checkNotNull(retryConfig, "retryConfig");
+ this.retryConfig = Optional.of(retryConfig);
+ return this;
+ }
+
+ public ListRolesRequestBuilder retryConfig(Optional retryConfig) {
+ Utils.checkNotNull(retryConfig, "retryConfig");
+ this.retryConfig = retryConfig;
+ return this;
+ }
+
+
+ private ListRolesRequest buildRequest() {
+ if (limit == null) {
+ limit = _SINGLETON_VALUE_Limit.value();
+ }
+
+ ListRolesRequest request = new ListRolesRequest(cursor,
+ limit);
+
+ return request;
+ }
+
+ public ListRolesResponse call() {
+ Optional options = Optional.of(Options.builder()
+ .retryConfig(retryConfig)
+ .build());
+
+ RequestOperation operation
+ = new ListRoles.Sync(sdkConfiguration, options, _headers);
+ ListRolesRequest request = buildRequest();
+
+ return operation.handleResponse(operation.doRequest(request));
+ }
+
+ /**
+ * Returns an iterable that performs next page calls till no more pages
+ * are returned.
+ *
+ * The returned iterable can be used in a for-each loop:
+ *
+ * for (ListRolesResponse page : builder.callAsIterable()) {
+ * // Process each page
+ * }
+ *
+ *
+ * @return An iterable that can be used to iterate through all pages
+ */
+ public Iterable callAsIterable() {
+ Optional options = Optional.of(Options.builder()
+ .retryConfig(retryConfig)
+ .build());
+
+ RequestOperation operation
+ = new ListRoles.Sync(sdkConfiguration, options, _headers);
+ ListRolesRequest request = buildRequest();
+ Iterator> iterator = new Paginator<>(
+ request,
+ new CursorTracker<>("$.next_cursor", String.class),
+ (req, pos) -> {
+ var modifiedReq = pos == null ? req : req.withCursor(pos);
+ return unchecked(() -> operation.doRequest(modifiedReq)).get();
+ });
+
+ return () -> transform(iterator, operation::handleResponse);
+ }
+
+ /**
+ * Returns a stream that performs next page calls till no more pages
+ * are returned.
+ **/
+ public Stream callAsStream() {
+ return toStream(callAsIterable());
+ }
+
+
+ private static final LazySingletonValue> _SINGLETON_VALUE_Limit =
+ new LazySingletonValue<>(
+ "limit",
+ "20",
+ new TypeReference>() {});
+}
diff --git a/src/main/java/com/gr4vy/sdk/models/operations/ListRolesResponse.java b/src/main/java/com/gr4vy/sdk/models/operations/ListRolesResponse.java
new file mode 100644
index 00000000..bb8d217c
--- /dev/null
+++ b/src/main/java/com/gr4vy/sdk/models/operations/ListRolesResponse.java
@@ -0,0 +1,253 @@
+/*
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
+ */
+package com.gr4vy.sdk.models.operations;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.gr4vy.sdk.models.components.CollectionRole;
+import com.gr4vy.sdk.utils.Response;
+import com.gr4vy.sdk.utils.Utils;
+import java.io.InputStream;
+import java.lang.Integer;
+import java.lang.Override;
+import java.lang.String;
+import java.lang.SuppressWarnings;
+import java.net.http.HttpResponse;
+import java.util.Optional;
+
+
+public class ListRolesResponse implements Response {
+ /**
+ * HTTP response content type for this operation
+ */
+ private String contentType;
+
+ /**
+ * HTTP response status code for this operation
+ */
+ private int statusCode;
+
+ /**
+ * Raw HTTP response; suitable for custom response parsing
+ */
+ private HttpResponse rawResponse;
+
+ /**
+ * Successful Response
+ */
+ private Optional extends CollectionRole> collectionRole;
+
+ @JsonCreator
+ public ListRolesResponse(
+ String contentType,
+ int statusCode,
+ HttpResponse rawResponse,
+ Optional extends CollectionRole> collectionRole) {
+ Utils.checkNotNull(contentType, "contentType");
+ Utils.checkNotNull(statusCode, "statusCode");
+ Utils.checkNotNull(rawResponse, "rawResponse");
+ Utils.checkNotNull(collectionRole, "collectionRole");
+ this.contentType = contentType;
+ this.statusCode = statusCode;
+ this.rawResponse = rawResponse;
+ this.collectionRole = collectionRole;
+ }
+
+ public ListRolesResponse(
+ String contentType,
+ int statusCode,
+ HttpResponse rawResponse) {
+ this(contentType, statusCode, rawResponse,
+ Optional.empty());
+ }
+
+ /**
+ * HTTP response content type for this operation
+ */
+ @JsonIgnore
+ public String contentType() {
+ return contentType;
+ }
+
+ /**
+ * HTTP response status code for this operation
+ */
+ @JsonIgnore
+ public int statusCode() {
+ return statusCode;
+ }
+
+ /**
+ * Raw HTTP response; suitable for custom response parsing
+ */
+ @JsonIgnore
+ public HttpResponse rawResponse() {
+ return rawResponse;
+ }
+
+ /**
+ * Successful Response
+ */
+ @SuppressWarnings("unchecked")
+ @JsonIgnore
+ public Optional collectionRole() {
+ return (Optional) collectionRole;
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+
+ /**
+ * HTTP response content type for this operation
+ */
+ public ListRolesResponse withContentType(String contentType) {
+ Utils.checkNotNull(contentType, "contentType");
+ this.contentType = contentType;
+ return this;
+ }
+
+ /**
+ * HTTP response status code for this operation
+ */
+ public ListRolesResponse withStatusCode(int statusCode) {
+ Utils.checkNotNull(statusCode, "statusCode");
+ this.statusCode = statusCode;
+ return this;
+ }
+
+ /**
+ * Raw HTTP response; suitable for custom response parsing
+ */
+ public ListRolesResponse withRawResponse(HttpResponse rawResponse) {
+ Utils.checkNotNull(rawResponse, "rawResponse");
+ this.rawResponse = rawResponse;
+ return this;
+ }
+
+ /**
+ * Successful Response
+ */
+ public ListRolesResponse withCollectionRole(CollectionRole collectionRole) {
+ Utils.checkNotNull(collectionRole, "collectionRole");
+ this.collectionRole = Optional.ofNullable(collectionRole);
+ return this;
+ }
+
+
+ /**
+ * Successful Response
+ */
+ public ListRolesResponse withCollectionRole(Optional extends CollectionRole> collectionRole) {
+ Utils.checkNotNull(collectionRole, "collectionRole");
+ this.collectionRole = collectionRole;
+ return this;
+ }
+
+ @Override
+ public boolean equals(java.lang.Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ ListRolesResponse other = (ListRolesResponse) o;
+ return
+ Utils.enhancedDeepEquals(this.contentType, other.contentType) &&
+ Utils.enhancedDeepEquals(this.statusCode, other.statusCode) &&
+ Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) &&
+ Utils.enhancedDeepEquals(this.collectionRole, other.collectionRole);
+ }
+
+ @Override
+ public int hashCode() {
+ return Utils.enhancedHash(
+ contentType, statusCode, rawResponse,
+ collectionRole);
+ }
+
+ @Override
+ public String toString() {
+ return Utils.toString(ListRolesResponse.class,
+ "contentType", contentType,
+ "statusCode", statusCode,
+ "rawResponse", rawResponse,
+ "collectionRole", collectionRole);
+ }
+
+ @SuppressWarnings("UnusedReturnValue")
+ public final static class Builder {
+
+ private String contentType;
+
+ private Integer statusCode;
+
+ private HttpResponse rawResponse;
+
+ private Optional extends CollectionRole> collectionRole = Optional.empty();
+
+ private Builder() {
+ // force use of static builder() method
+ }
+
+
+ /**
+ * HTTP response content type for this operation
+ */
+ public Builder contentType(String contentType) {
+ Utils.checkNotNull(contentType, "contentType");
+ this.contentType = contentType;
+ return this;
+ }
+
+
+ /**
+ * HTTP response status code for this operation
+ */
+ public Builder statusCode(int statusCode) {
+ Utils.checkNotNull(statusCode, "statusCode");
+ this.statusCode = statusCode;
+ return this;
+ }
+
+
+ /**
+ * Raw HTTP response; suitable for custom response parsing
+ */
+ public Builder rawResponse(HttpResponse rawResponse) {
+ Utils.checkNotNull(rawResponse, "rawResponse");
+ this.rawResponse = rawResponse;
+ return this;
+ }
+
+
+ /**
+ * Successful Response
+ */
+ public Builder collectionRole(CollectionRole collectionRole) {
+ Utils.checkNotNull(collectionRole, "collectionRole");
+ this.collectionRole = Optional.ofNullable(collectionRole);
+ return this;
+ }
+
+ /**
+ * Successful Response
+ */
+ public Builder collectionRole(Optional extends CollectionRole> collectionRole) {
+ Utils.checkNotNull(collectionRole, "collectionRole");
+ this.collectionRole = collectionRole;
+ return this;
+ }
+
+ public ListRolesResponse build() {
+
+ return new ListRolesResponse(
+ contentType, statusCode, rawResponse,
+ collectionRole);
+ }
+
+ }
+}
diff --git a/src/main/java/com/gr4vy/sdk/models/operations/async/ListRolesRequestBuilder.java b/src/main/java/com/gr4vy/sdk/models/operations/async/ListRolesRequestBuilder.java
new file mode 100644
index 00000000..98ec48da
--- /dev/null
+++ b/src/main/java/com/gr4vy/sdk/models/operations/async/ListRolesRequestBuilder.java
@@ -0,0 +1,154 @@
+/*
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
+ */
+package com.gr4vy.sdk.models.operations.async;
+
+import static com.gr4vy.sdk.operations.Operations.AsyncRequestOperation;
+import static com.gr4vy.sdk.utils.reactive.ReactiveUtils.mapAsync;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.gr4vy.sdk.SDKConfiguration;
+import com.gr4vy.sdk.models.operations.ListRolesRequest;
+import com.gr4vy.sdk.operations.ListRoles;
+import com.gr4vy.sdk.utils.Blob;
+import com.gr4vy.sdk.utils.Headers;
+import com.gr4vy.sdk.utils.LazySingletonValue;
+import com.gr4vy.sdk.utils.Options;
+import com.gr4vy.sdk.utils.RetryConfig;
+import com.gr4vy.sdk.utils.Utils;
+import com.gr4vy.sdk.utils.pagination.AsyncPaginator;
+import com.gr4vy.sdk.utils.pagination.CursorTracker;
+import java.lang.Long;
+import java.lang.String;
+import java.net.http.HttpResponse;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Flow;
+import org.openapitools.jackson.nullable.JsonNullable;
+import org.reactivestreams.FlowAdapters;
+import org.reactivestreams.Publisher;
+
+public class ListRolesRequestBuilder {
+
+ private JsonNullable cursor = JsonNullable.undefined();
+ private Optional limit = Utils.readDefaultOrConstValue(
+ "limit",
+ "20",
+ new TypeReference>() {});
+ private Optional retryConfig = Optional.empty();
+ private final SDKConfiguration sdkConfiguration;
+ private final Headers _headers = new Headers();
+
+ public ListRolesRequestBuilder(SDKConfiguration sdkConfiguration) {
+ this.sdkConfiguration = sdkConfiguration;
+ }
+
+ public ListRolesRequestBuilder cursor(String cursor) {
+ Utils.checkNotNull(cursor, "cursor");
+ this.cursor = JsonNullable.of(cursor);
+ return this;
+ }
+
+ public ListRolesRequestBuilder cursor(JsonNullable cursor) {
+ Utils.checkNotNull(cursor, "cursor");
+ this.cursor = cursor;
+ return this;
+ }
+
+ public ListRolesRequestBuilder limit(long limit) {
+ Utils.checkNotNull(limit, "limit");
+ this.limit = Optional.of(limit);
+ return this;
+ }
+
+ public ListRolesRequestBuilder limit(Optional limit) {
+ Utils.checkNotNull(limit, "limit");
+ this.limit = limit;
+ return this;
+ }
+
+ public ListRolesRequestBuilder retryConfig(RetryConfig retryConfig) {
+ Utils.checkNotNull(retryConfig, "retryConfig");
+ this.retryConfig = Optional.of(retryConfig);
+ return this;
+ }
+
+ public ListRolesRequestBuilder retryConfig(Optional retryConfig) {
+ Utils.checkNotNull(retryConfig, "retryConfig");
+ this.retryConfig = retryConfig;
+ return this;
+ }
+
+
+ private ListRolesRequest buildRequest() {
+ if (limit == null) {
+ limit = _SINGLETON_VALUE_Limit.value();
+ }
+
+ ListRolesRequest request = new ListRolesRequest(cursor,
+ limit);
+
+ return request;
+ }
+
+ public CompletableFuture call() {
+ Optional options = Optional.of(Options.builder()
+ .retryConfig(retryConfig)
+ .build());
+
+ AsyncRequestOperation operation
+ = new ListRoles.Async(
+ sdkConfiguration, options, sdkConfiguration.retryScheduler(),
+ _headers);
+ ListRolesRequest request = buildRequest();
+
+ return operation.doRequest(request)
+ .thenCompose(operation::handleResponse);
+ }
+
+ /**
+ * Returns a Publisher that performs next page calls till no more pages
+ * are returned.
+ *
+ * The returned publisher can be used with reactive frameworks:
+ *
+ * Publisher<ListRolesResponse> publisher = builder.callAsPublisher();
+ * publisher.subscribe(new Subscriber<ListRolesResponse>() {
+ * // Handle onNext, onError, onComplete
+ * });
+ *
+ *
+ * @return A Publisher that emits pages asynchronously
+ */
+ public Publisher callAsPublisher() {
+ ListRolesRequest request = this.buildRequest();
+ Optional options = Optional.of(Options.builder()
+ .retryConfig(retryConfig)
+ .build());
+
+ AsyncRequestOperation operation
+ = new ListRoles.Async(
+ sdkConfiguration, options, sdkConfiguration.retryScheduler(),
+ _headers);
+
+ Flow.Publisher> asyncPaginator = new AsyncPaginator<>(
+ request,
+ new CursorTracker<>("$.next_cursor", String.class),
+ (req, pos) -> {
+ var modifiedReq = pos == null ? req : req.withCursor(pos);
+ return operation.doRequest(modifiedReq);
+ });
+
+ Flow.Publisher flowPublisher = mapAsync(asyncPaginator, operation::handleResponse);
+
+ // Convert Flow.Publisher to Reactive Streams Publisher at the last stage
+ return FlowAdapters.toPublisher(flowPublisher);
+ }
+
+
+ private static final LazySingletonValue> _SINGLETON_VALUE_Limit =
+ new LazySingletonValue<>(
+ "limit",
+ "20",
+ new TypeReference>() {});
+}
diff --git a/src/main/java/com/gr4vy/sdk/models/operations/async/ListRolesResponse.java b/src/main/java/com/gr4vy/sdk/models/operations/async/ListRolesResponse.java
new file mode 100644
index 00000000..9f648437
--- /dev/null
+++ b/src/main/java/com/gr4vy/sdk/models/operations/async/ListRolesResponse.java
@@ -0,0 +1,253 @@
+/*
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
+ */
+package com.gr4vy.sdk.models.operations.async;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.gr4vy.sdk.models.components.CollectionRole;
+import com.gr4vy.sdk.utils.AsyncResponse;
+import com.gr4vy.sdk.utils.Blob;
+import com.gr4vy.sdk.utils.Utils;
+import java.lang.Integer;
+import java.lang.Override;
+import java.lang.String;
+import java.lang.SuppressWarnings;
+import java.net.http.HttpResponse;
+import java.util.Optional;
+
+
+public class ListRolesResponse implements AsyncResponse {
+ /**
+ * HTTP response content type for this operation
+ */
+ private String contentType;
+
+ /**
+ * HTTP response status code for this operation
+ */
+ private int statusCode;
+
+ /**
+ * Raw HTTP response; suitable for custom response parsing
+ */
+ private HttpResponse rawResponse;
+
+ /**
+ * Successful Response
+ */
+ private Optional extends CollectionRole> collectionRole;
+
+ @JsonCreator
+ public ListRolesResponse(
+ String contentType,
+ int statusCode,
+ HttpResponse rawResponse,
+ Optional extends CollectionRole> collectionRole) {
+ Utils.checkNotNull(contentType, "contentType");
+ Utils.checkNotNull(statusCode, "statusCode");
+ Utils.checkNotNull(rawResponse, "rawResponse");
+ Utils.checkNotNull(collectionRole, "collectionRole");
+ this.contentType = contentType;
+ this.statusCode = statusCode;
+ this.rawResponse = rawResponse;
+ this.collectionRole = collectionRole;
+ }
+
+ public ListRolesResponse(
+ String contentType,
+ int statusCode,
+ HttpResponse rawResponse) {
+ this(contentType, statusCode, rawResponse,
+ Optional.empty());
+ }
+
+ /**
+ * HTTP response content type for this operation
+ */
+ @JsonIgnore
+ public String contentType() {
+ return contentType;
+ }
+
+ /**
+ * HTTP response status code for this operation
+ */
+ @JsonIgnore
+ public int statusCode() {
+ return statusCode;
+ }
+
+ /**
+ * Raw HTTP response; suitable for custom response parsing
+ */
+ @JsonIgnore
+ public HttpResponse rawResponse() {
+ return rawResponse;
+ }
+
+ /**
+ * Successful Response
+ */
+ @SuppressWarnings("unchecked")
+ @JsonIgnore
+ public Optional collectionRole() {
+ return (Optional) collectionRole;
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+
+ /**
+ * HTTP response content type for this operation
+ */
+ public ListRolesResponse withContentType(String contentType) {
+ Utils.checkNotNull(contentType, "contentType");
+ this.contentType = contentType;
+ return this;
+ }
+
+ /**
+ * HTTP response status code for this operation
+ */
+ public ListRolesResponse withStatusCode(int statusCode) {
+ Utils.checkNotNull(statusCode, "statusCode");
+ this.statusCode = statusCode;
+ return this;
+ }
+
+ /**
+ * Raw HTTP response; suitable for custom response parsing
+ */
+ public ListRolesResponse withRawResponse(HttpResponse rawResponse) {
+ Utils.checkNotNull(rawResponse, "rawResponse");
+ this.rawResponse = rawResponse;
+ return this;
+ }
+
+ /**
+ * Successful Response
+ */
+ public ListRolesResponse withCollectionRole(CollectionRole collectionRole) {
+ Utils.checkNotNull(collectionRole, "collectionRole");
+ this.collectionRole = Optional.ofNullable(collectionRole);
+ return this;
+ }
+
+
+ /**
+ * Successful Response
+ */
+ public ListRolesResponse withCollectionRole(Optional extends CollectionRole> collectionRole) {
+ Utils.checkNotNull(collectionRole, "collectionRole");
+ this.collectionRole = collectionRole;
+ return this;
+ }
+
+ @Override
+ public boolean equals(java.lang.Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ ListRolesResponse other = (ListRolesResponse) o;
+ return
+ Utils.enhancedDeepEquals(this.contentType, other.contentType) &&
+ Utils.enhancedDeepEquals(this.statusCode, other.statusCode) &&
+ Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) &&
+ Utils.enhancedDeepEquals(this.collectionRole, other.collectionRole);
+ }
+
+ @Override
+ public int hashCode() {
+ return Utils.enhancedHash(
+ contentType, statusCode, rawResponse,
+ collectionRole);
+ }
+
+ @Override
+ public String toString() {
+ return Utils.toString(ListRolesResponse.class,
+ "contentType", contentType,
+ "statusCode", statusCode,
+ "rawResponse", rawResponse,
+ "collectionRole", collectionRole);
+ }
+
+ @SuppressWarnings("UnusedReturnValue")
+ public final static class Builder {
+
+ private String contentType;
+
+ private Integer statusCode;
+
+ private HttpResponse rawResponse;
+
+ private Optional extends CollectionRole> collectionRole = Optional.empty();
+
+ private Builder() {
+ // force use of static builder() method
+ }
+
+
+ /**
+ * HTTP response content type for this operation
+ */
+ public Builder contentType(String contentType) {
+ Utils.checkNotNull(contentType, "contentType");
+ this.contentType = contentType;
+ return this;
+ }
+
+
+ /**
+ * HTTP response status code for this operation
+ */
+ public Builder statusCode(int statusCode) {
+ Utils.checkNotNull(statusCode, "statusCode");
+ this.statusCode = statusCode;
+ return this;
+ }
+
+
+ /**
+ * Raw HTTP response; suitable for custom response parsing
+ */
+ public Builder rawResponse(HttpResponse rawResponse) {
+ Utils.checkNotNull(rawResponse, "rawResponse");
+ this.rawResponse = rawResponse;
+ return this;
+ }
+
+
+ /**
+ * Successful Response
+ */
+ public Builder collectionRole(CollectionRole collectionRole) {
+ Utils.checkNotNull(collectionRole, "collectionRole");
+ this.collectionRole = Optional.ofNullable(collectionRole);
+ return this;
+ }
+
+ /**
+ * Successful Response
+ */
+ public Builder collectionRole(Optional extends CollectionRole> collectionRole) {
+ Utils.checkNotNull(collectionRole, "collectionRole");
+ this.collectionRole = collectionRole;
+ return this;
+ }
+
+ public ListRolesResponse build() {
+
+ return new ListRolesResponse(
+ contentType, statusCode, rawResponse,
+ collectionRole);
+ }
+
+ }
+}
diff --git a/src/main/java/com/gr4vy/sdk/operations/ListRoles.java b/src/main/java/com/gr4vy/sdk/operations/ListRoles.java
new file mode 100644
index 00000000..03278605
--- /dev/null
+++ b/src/main/java/com/gr4vy/sdk/operations/ListRoles.java
@@ -0,0 +1,490 @@
+/*
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
+ */
+package com.gr4vy.sdk.operations;
+
+import static com.gr4vy.sdk.operations.Operations.RequestOperation;
+import static com.gr4vy.sdk.utils.Exceptions.unchecked;
+import static com.gr4vy.sdk.operations.Operations.AsyncRequestOperation;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.gr4vy.sdk.SDKConfiguration;
+import com.gr4vy.sdk.SecuritySource;
+import com.gr4vy.sdk.models.components.CollectionRole;
+import com.gr4vy.sdk.models.errors.APIException;
+import com.gr4vy.sdk.models.errors.Error400;
+import com.gr4vy.sdk.models.errors.Error401;
+import com.gr4vy.sdk.models.errors.Error403;
+import com.gr4vy.sdk.models.errors.Error404;
+import com.gr4vy.sdk.models.errors.Error405;
+import com.gr4vy.sdk.models.errors.Error409;
+import com.gr4vy.sdk.models.errors.Error425;
+import com.gr4vy.sdk.models.errors.Error429;
+import com.gr4vy.sdk.models.errors.Error500;
+import com.gr4vy.sdk.models.errors.Error502;
+import com.gr4vy.sdk.models.errors.Error504;
+import com.gr4vy.sdk.models.errors.HTTPValidationError;
+import com.gr4vy.sdk.models.operations.ListRolesRequest;
+import com.gr4vy.sdk.models.operations.ListRolesResponse;
+import com.gr4vy.sdk.utils.AsyncRetries;
+import com.gr4vy.sdk.utils.BackoffStrategy;
+import com.gr4vy.sdk.utils.Blob;
+import com.gr4vy.sdk.utils.HTTPClient;
+import com.gr4vy.sdk.utils.HTTPRequest;
+import com.gr4vy.sdk.utils.Headers;
+import com.gr4vy.sdk.utils.Hook.AfterErrorContextImpl;
+import com.gr4vy.sdk.utils.Hook.AfterSuccessContextImpl;
+import com.gr4vy.sdk.utils.Hook.BeforeRequestContextImpl;
+import com.gr4vy.sdk.utils.NonRetryableException;
+import com.gr4vy.sdk.utils.Options;
+import com.gr4vy.sdk.utils.Retries;
+import com.gr4vy.sdk.utils.RetryConfig;
+import com.gr4vy.sdk.utils.Utils;
+import java.io.InputStream;
+import java.lang.Exception;
+import java.lang.String;
+import java.lang.Throwable;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Function;
+
+
+public class ListRoles {
+
+ static abstract class Base {
+ final SDKConfiguration sdkConfiguration;
+ final String baseUrl;
+ final SecuritySource securitySource;
+ final List retryStatusCodes;
+ final RetryConfig retryConfig;
+ final HTTPClient client;
+ final Headers _headers;
+
+ public Base(
+ SDKConfiguration sdkConfiguration, Optional options,
+ Headers _headers) {
+ this.sdkConfiguration = sdkConfiguration;
+ this._headers =_headers;
+ this.baseUrl = Utils.templateUrl(
+ this.sdkConfiguration.serverUrl(), this.sdkConfiguration.getServerVariableDefaults());
+ this.securitySource = this.sdkConfiguration.securitySource();
+ options
+ .ifPresent(o -> o.validate(List.of(Options.Option.RETRY_CONFIG)));
+ this.retryStatusCodes = List.of("5XX");
+ this.retryConfig = options
+ .flatMap(Options::retryConfig)
+ .or(sdkConfiguration::retryConfig)
+ .orElse(RetryConfig.builder().backoff(BackoffStrategy.builder()
+ .initialInterval(200, TimeUnit.MILLISECONDS)
+ .maxInterval(200, TimeUnit.MILLISECONDS)
+ .baseFactor((double) (1))
+ .maxElapsedTime(1000, TimeUnit.MILLISECONDS)
+ .retryConnectError(true)
+ .build())
+ .build());
+ this.client = this.sdkConfiguration.client();
+ }
+
+ Optional securitySource() {
+ return Optional.ofNullable(this.securitySource);
+ }
+
+ BeforeRequestContextImpl createBeforeRequestContext() {
+ return new BeforeRequestContextImpl(
+ this.sdkConfiguration,
+ this.baseUrl,
+ "list_roles",
+ java.util.Optional.empty(),
+ securitySource());
+ }
+
+ AfterSuccessContextImpl createAfterSuccessContext() {
+ return new AfterSuccessContextImpl(
+ this.sdkConfiguration,
+ this.baseUrl,
+ "list_roles",
+ java.util.Optional.empty(),
+ securitySource());
+ }
+
+ AfterErrorContextImpl createAfterErrorContext() {
+ return new AfterErrorContextImpl(
+ this.sdkConfiguration,
+ this.baseUrl,
+ "list_roles",
+ java.util.Optional.empty(),
+ securitySource());
+ }
+ HttpRequest buildRequest(T request, Class klass) throws Exception {
+ String url = Utils.generateURL(
+ this.baseUrl,
+ "/roles");
+ HTTPRequest req = new HTTPRequest(url, "GET");
+ req.addHeader("Accept", "application/json")
+ .addHeader("user-agent", SDKConfiguration.USER_AGENT);
+ _headers.forEach((k, list) -> list.forEach(v -> req.addHeader(k, v)));
+
+ req.addQueryParams(Utils.getQueryParams(
+ klass,
+ request,
+ null));
+ Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity());
+
+ return req.build();
+ }
+ }
+
+ public static class Sync extends Base
+ implements RequestOperation {
+ public Sync(
+ SDKConfiguration sdkConfiguration, Optional options,
+ Headers _headers) {
+ super(
+ sdkConfiguration, options,
+ _headers);
+ }
+
+ private HttpRequest onBuildRequest(ListRolesRequest request) throws Exception {
+ HttpRequest req = buildRequest(request, ListRolesRequest.class);
+ return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req);
+ }
+
+ private HttpResponse onError(HttpResponse response, Exception error) throws Exception {
+ return sdkConfiguration.hooks().afterError(
+ createAfterErrorContext(),
+ Optional.ofNullable(response),
+ Optional.ofNullable(error));
+ }
+
+ private HttpResponse onSuccess(HttpResponse response) throws Exception {
+ return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response);
+ }
+
+ @Override
+ public HttpResponse doRequest(ListRolesRequest request) {
+ Retries retries = Retries.builder()
+ .action(() -> {
+ HttpRequest r;
+ try {
+ r = onBuildRequest(request);
+ } catch (Exception e) {
+ throw new NonRetryableException(e);
+ }
+ try {
+ HttpResponse httpRes = client.send(r);
+ if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) {
+ return onError(httpRes, null);
+ }
+ return httpRes;
+ } catch (Exception e) {
+ return onError(null, e);
+ }
+ })
+ .retryConfig(retryConfig)
+ .statusCodes(retryStatusCodes)
+ .build();
+ return unchecked(() -> onSuccess(retries.run())).get();
+ }
+
+
+ @Override
+ public ListRolesResponse handleResponse(HttpResponse response) {
+ String contentType = response
+ .headers()
+ .firstValue("Content-Type")
+ .orElse("application/octet-stream");
+ ListRolesResponse.Builder resBuilder =
+ ListRolesResponse
+ .builder()
+ .contentType(contentType)
+ .statusCode(response.statusCode())
+ .rawResponse(response);
+
+ ListRolesResponse res = resBuilder.build();
+
+ if (Utils.statusCodeMatches(response.statusCode(), "200")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ return res.withCollectionRole(Utils.unmarshal(response, new TypeReference() {}));
+ } else {
+ throw APIException.from("Unexpected content-type received: " + contentType, response);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "400")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ throw Error400.from(response);
+ } else {
+ throw APIException.from("Unexpected content-type received: " + contentType, response);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "401")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ throw Error401.from(response);
+ } else {
+ throw APIException.from("Unexpected content-type received: " + contentType, response);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "403")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ throw Error403.from(response);
+ } else {
+ throw APIException.from("Unexpected content-type received: " + contentType, response);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "404")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ throw Error404.from(response);
+ } else {
+ throw APIException.from("Unexpected content-type received: " + contentType, response);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "405")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ throw Error405.from(response);
+ } else {
+ throw APIException.from("Unexpected content-type received: " + contentType, response);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "409")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ throw Error409.from(response);
+ } else {
+ throw APIException.from("Unexpected content-type received: " + contentType, response);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "422")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ throw HTTPValidationError.from(response);
+ } else {
+ throw APIException.from("Unexpected content-type received: " + contentType, response);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "425")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ throw Error425.from(response);
+ } else {
+ throw APIException.from("Unexpected content-type received: " + contentType, response);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "429")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ throw Error429.from(response);
+ } else {
+ throw APIException.from("Unexpected content-type received: " + contentType, response);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "500")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ throw Error500.from(response);
+ } else {
+ throw APIException.from("Unexpected content-type received: " + contentType, response);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "502")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ throw Error502.from(response);
+ } else {
+ throw APIException.from("Unexpected content-type received: " + contentType, response);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "504")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ throw Error504.from(response);
+ } else {
+ throw APIException.from("Unexpected content-type received: " + contentType, response);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "4XX")) {
+ // no content
+ throw APIException.from("API error occurred", response);
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "5XX")) {
+ // no content
+ throw APIException.from("API error occurred", response);
+ }
+ throw APIException.from("Unexpected status code received: " + response.statusCode(), response);
+ }
+ }
+ public static class Async extends Base
+ implements AsyncRequestOperation {
+ private final ScheduledExecutorService retryScheduler;
+
+ public Async(
+ SDKConfiguration sdkConfiguration, Optional options,
+ ScheduledExecutorService retryScheduler, Headers _headers) {
+ super(
+ sdkConfiguration, options,
+ _headers);
+ this.retryScheduler = retryScheduler;
+ }
+
+ private CompletableFuture onBuildRequest(ListRolesRequest request) throws Exception {
+ HttpRequest req = buildRequest(request, ListRolesRequest.class);
+ return this.sdkConfiguration.asyncHooks().beforeRequest(createBeforeRequestContext(), req);
+ }
+
+ private CompletableFuture> onError(HttpResponse response, Throwable error) {
+ return this.sdkConfiguration.asyncHooks().afterError(createAfterErrorContext(), response, error);
+ }
+
+ private CompletableFuture> onSuccess(HttpResponse response) {
+ return this.sdkConfiguration.asyncHooks().afterSuccess(createAfterSuccessContext(), response);
+ }
+
+ @Override
+ public CompletableFuture> doRequest(ListRolesRequest request) {
+ AsyncRetries retries = AsyncRetries.builder()
+ .retryConfig(retryConfig)
+ .statusCodes(retryStatusCodes)
+ .scheduler(retryScheduler)
+ .build();
+ return retries.retry(() -> unchecked(() -> onBuildRequest(request)).get().thenCompose(client::sendAsync)
+ .handle((resp, err) -> {
+ if (err != null) {
+ return onError(null, err);
+ }
+ if (Utils.statusCodeMatches(resp.statusCode(), "4XX", "5XX")) {
+ return onError(resp, null);
+ }
+ return CompletableFuture.completedFuture(resp);
+ })
+ .thenCompose(Function.identity()))
+ .thenCompose(this::onSuccess);
+ }
+
+ @Override
+ public CompletableFuture handleResponse(
+ HttpResponse response) {
+ String contentType = response
+ .headers()
+ .firstValue("Content-Type")
+ .orElse("application/octet-stream");
+ com.gr4vy.sdk.models.operations.async.ListRolesResponse.Builder resBuilder =
+ com.gr4vy.sdk.models.operations.async.ListRolesResponse
+ .builder()
+ .contentType(contentType)
+ .statusCode(response.statusCode())
+ .rawResponse(response);
+
+ com.gr4vy.sdk.models.operations.async.ListRolesResponse res = resBuilder.build();
+
+ if (Utils.statusCodeMatches(response.statusCode(), "200")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ return Utils.unmarshalAsync(response, new TypeReference() {})
+ .thenApply(res::withCollectionRole);
+ } else {
+ return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "400")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ return Error400.fromAsync(response)
+ .thenCompose(CompletableFuture::failedFuture);
+ } else {
+ return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "401")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ return Error401.fromAsync(response)
+ .thenCompose(CompletableFuture::failedFuture);
+ } else {
+ return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "403")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ return Error403.fromAsync(response)
+ .thenCompose(CompletableFuture::failedFuture);
+ } else {
+ return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "404")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ return Error404.fromAsync(response)
+ .thenCompose(CompletableFuture::failedFuture);
+ } else {
+ return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "405")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ return Error405.fromAsync(response)
+ .thenCompose(CompletableFuture::failedFuture);
+ } else {
+ return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "409")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ return Error409.fromAsync(response)
+ .thenCompose(CompletableFuture::failedFuture);
+ } else {
+ return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "422")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ return HTTPValidationError.fromAsync(response)
+ .thenCompose(CompletableFuture::failedFuture);
+ } else {
+ return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "425")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ return Error425.fromAsync(response)
+ .thenCompose(CompletableFuture::failedFuture);
+ } else {
+ return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "429")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ return Error429.fromAsync(response)
+ .thenCompose(CompletableFuture::failedFuture);
+ } else {
+ return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "500")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ return Error500.fromAsync(response)
+ .thenCompose(CompletableFuture::failedFuture);
+ } else {
+ return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "502")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ return Error502.fromAsync(response)
+ .thenCompose(CompletableFuture::failedFuture);
+ } else {
+ return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "504")) {
+ if (Utils.contentTypeMatches(contentType, "application/json")) {
+ return Error504.fromAsync(response)
+ .thenCompose(CompletableFuture::failedFuture);
+ } else {
+ return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType);
+ }
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "4XX")) {
+ // no content
+ return Utils.createAsyncApiError(response, "API error occurred");
+ }
+ if (Utils.statusCodeMatches(response.statusCode(), "5XX")) {
+ // no content
+ return Utils.createAsyncApiError(response, "API error occurred");
+ }
+ return Utils.createAsyncApiError(response, "Unexpected status code received: " + response.statusCode());
+ }
+ }
+}