Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions scripts/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,11 @@ for pkg in api client models; do
"src/main/java/com/getconvoy/$pkg/"
done

# Post-process: the stock generator template only reinitializes a JsonNullable
# map when the wrapper is undefined. After setX(null) or deserializing JSON
# null the wrapper is present with a null map and put*Item NPEs on get().put().
# Extend the guard to also recreate the map when the present value is null.
perl -pi -e 's/if \(this\.(\w+) == null \|\| !this\.\1\.isPresent\(\)\) \{/if (this.$1 == null || !this.$1.isPresent() || this.$1.get() == null) {/' \
src/main/java/com/getconvoy/models/*.java

echo "Generated client synced into src/main/java/com/getconvoy/{api,client,models}"
32 changes: 16 additions & 16 deletions src/main/java/com/getconvoy/api/OnboardApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

import com.getconvoy.models.BulkOnboard200Response;
import com.getconvoy.models.BulkOnboard202Response;
import java.io.File;
import com.getconvoy.models.GetProjects400Response;
import com.getconvoy.models.ModelsBulkOnboardRequest;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -170,26 +170,26 @@ private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOEx
* This endpoint accepts a CSV file or JSON body to bulk-create endpoints with subscriptions
* @param projectID Project ID (required)
* @param dryRun Validate without creating (optional)
* @param body Onboard Details (JSON) (optional)
* @param modelsBulkOnboardRequest Onboard Details (JSON) (optional)
* @return BulkOnboard200Response
* @throws ApiException if fails to make API call
*/
public BulkOnboard200Response bulkOnboard(@jakarta.annotation.Nonnull String projectID, @jakarta.annotation.Nullable Boolean dryRun, @jakarta.annotation.Nullable File body) throws ApiException {
return bulkOnboard(projectID, dryRun, body, null);
public BulkOnboard200Response bulkOnboard(@jakarta.annotation.Nonnull String projectID, @jakarta.annotation.Nullable Boolean dryRun, @jakarta.annotation.Nullable ModelsBulkOnboardRequest modelsBulkOnboardRequest) throws ApiException {
return bulkOnboard(projectID, dryRun, modelsBulkOnboardRequest, null);
}

/**
* Bulk onboard endpoints with subscriptions
* This endpoint accepts a CSV file or JSON body to bulk-create endpoints with subscriptions
* @param projectID Project ID (required)
* @param dryRun Validate without creating (optional)
* @param body Onboard Details (JSON) (optional)
* @param modelsBulkOnboardRequest Onboard Details (JSON) (optional)
* @param headers Optional headers to include in the request
* @return BulkOnboard200Response
* @throws ApiException if fails to make API call
*/
public BulkOnboard200Response bulkOnboard(@jakarta.annotation.Nonnull String projectID, @jakarta.annotation.Nullable Boolean dryRun, @jakarta.annotation.Nullable File body, Map<String, String> headers) throws ApiException {
ApiResponse<BulkOnboard200Response> localVarResponse = bulkOnboardWithHttpInfo(projectID, dryRun, body, headers);
public BulkOnboard200Response bulkOnboard(@jakarta.annotation.Nonnull String projectID, @jakarta.annotation.Nullable Boolean dryRun, @jakarta.annotation.Nullable ModelsBulkOnboardRequest modelsBulkOnboardRequest, Map<String, String> headers) throws ApiException {
ApiResponse<BulkOnboard200Response> localVarResponse = bulkOnboardWithHttpInfo(projectID, dryRun, modelsBulkOnboardRequest, headers);
return localVarResponse.getData();
}

Expand All @@ -198,26 +198,26 @@ public BulkOnboard200Response bulkOnboard(@jakarta.annotation.Nonnull String pro
* This endpoint accepts a CSV file or JSON body to bulk-create endpoints with subscriptions
* @param projectID Project ID (required)
* @param dryRun Validate without creating (optional)
* @param body Onboard Details (JSON) (optional)
* @param modelsBulkOnboardRequest Onboard Details (JSON) (optional)
* @return ApiResponse&lt;BulkOnboard200Response&gt;
* @throws ApiException if fails to make API call
*/
public ApiResponse<BulkOnboard200Response> bulkOnboardWithHttpInfo(@jakarta.annotation.Nonnull String projectID, @jakarta.annotation.Nullable Boolean dryRun, @jakarta.annotation.Nullable File body) throws ApiException {
return bulkOnboardWithHttpInfo(projectID, dryRun, body, null);
public ApiResponse<BulkOnboard200Response> bulkOnboardWithHttpInfo(@jakarta.annotation.Nonnull String projectID, @jakarta.annotation.Nullable Boolean dryRun, @jakarta.annotation.Nullable ModelsBulkOnboardRequest modelsBulkOnboardRequest) throws ApiException {
return bulkOnboardWithHttpInfo(projectID, dryRun, modelsBulkOnboardRequest, null);
}

/**
* Bulk onboard endpoints with subscriptions
* This endpoint accepts a CSV file or JSON body to bulk-create endpoints with subscriptions
* @param projectID Project ID (required)
* @param dryRun Validate without creating (optional)
* @param body Onboard Details (JSON) (optional)
* @param modelsBulkOnboardRequest Onboard Details (JSON) (optional)
* @param headers Optional headers to include in the request
* @return ApiResponse&lt;BulkOnboard200Response&gt;
* @throws ApiException if fails to make API call
*/
public ApiResponse<BulkOnboard200Response> bulkOnboardWithHttpInfo(@jakarta.annotation.Nonnull String projectID, @jakarta.annotation.Nullable Boolean dryRun, @jakarta.annotation.Nullable File body, Map<String, String> headers) throws ApiException {
HttpRequest.Builder localVarRequestBuilder = bulkOnboardRequestBuilder(projectID, dryRun, body, headers);
public ApiResponse<BulkOnboard200Response> bulkOnboardWithHttpInfo(@jakarta.annotation.Nonnull String projectID, @jakarta.annotation.Nullable Boolean dryRun, @jakarta.annotation.Nullable ModelsBulkOnboardRequest modelsBulkOnboardRequest, Map<String, String> headers) throws ApiException {
HttpRequest.Builder localVarRequestBuilder = bulkOnboardRequestBuilder(projectID, dryRun, modelsBulkOnboardRequest, headers);
try {
HttpResponse<InputStream> localVarResponse = memberVarHttpClient.send(
localVarRequestBuilder.build(),
Expand Down Expand Up @@ -264,7 +264,7 @@ public ApiResponse<BulkOnboard200Response> bulkOnboardWithHttpInfo(@jakarta.anno
}
}

private HttpRequest.Builder bulkOnboardRequestBuilder(@jakarta.annotation.Nonnull String projectID, @jakarta.annotation.Nullable Boolean dryRun, @jakarta.annotation.Nullable File body, Map<String, String> headers) throws ApiException {
private HttpRequest.Builder bulkOnboardRequestBuilder(@jakarta.annotation.Nonnull String projectID, @jakarta.annotation.Nullable Boolean dryRun, @jakarta.annotation.Nullable ModelsBulkOnboardRequest modelsBulkOnboardRequest, Map<String, String> headers) throws ApiException {
// verify the required parameter 'projectID' is set
if (projectID == null) {
throw new ApiException(400, "Missing the required parameter 'projectID' when calling bulkOnboard");
Expand Down Expand Up @@ -292,11 +292,11 @@ private HttpRequest.Builder bulkOnboardRequestBuilder(@jakarta.annotation.Nonnul
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
}

localVarRequestBuilder.header("Content-Type", "application/octet-stream");
localVarRequestBuilder.header("Content-Type", "application/json");
localVarRequestBuilder.header("Accept", "application/json");

try {
byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(body);
byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(modelsBulkOnboardRequest);
localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody));
} catch (IOException e) {
throw new ApiException(e);
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/getconvoy/models/AuthRoleType.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ public enum AuthRoleType {
/**
*
*/
RoleAPI("api");
RoleAPI("api"),

EMPTY("");
Comment thread
mekilis marked this conversation as resolved.

private String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
*/
public enum ConfigRequestIDHeaderProvider {

DefaultRequestIDHeader("X-Convoy-Idempotency-Key");
DefaultRequestIDHeader("X-Convoy-Idempotency-Key"),

EMPTY("");

private String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
*/
public enum ConfigSignatureHeaderProvider {

DefaultSignatureHeader("X-Convoy-Signature");
DefaultSignatureHeader("X-Convoy-Signature"),

EMPTY("");

private String value;

Expand Down
42 changes: 32 additions & 10 deletions src/main/java/com/getconvoy/models/DatastoreAPIKeyResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
import com.fasterxml.jackson.annotation.JsonValue;
import com.getconvoy.models.DatastoreRole;
import java.util.Arrays;
import org.openapitools.jackson.nullable.JsonNullable;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.openapitools.jackson.nullable.JsonNullable;
import java.util.NoSuchElementException;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;


Expand All @@ -50,8 +54,7 @@ public class DatastoreAPIKeyResponse {
private String createdAt;

public static final String JSON_PROPERTY_EXPIRES_AT = "expires_at";
@jakarta.annotation.Nullable
private String expiresAt;
private JsonNullable<String> expiresAt = JsonNullable.<String>undefined();

public static final String JSON_PROPERTY_KEY = "key";
@jakarta.annotation.Nullable
Expand Down Expand Up @@ -105,7 +108,7 @@ public void setCreatedAt(@jakarta.annotation.Nullable String createdAt) {


public DatastoreAPIKeyResponse expiresAt(@jakarta.annotation.Nullable String expiresAt) {
this.expiresAt = expiresAt;
this.expiresAt = JsonNullable.<String>of(expiresAt);
return this;
}

Expand All @@ -114,19 +117,27 @@ public DatastoreAPIKeyResponse expiresAt(@jakarta.annotation.Nullable String exp
* @return expiresAt
*/
@jakarta.annotation.Nullable
@JsonProperty(value = JSON_PROPERTY_EXPIRES_AT, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
@JsonIgnore
public String getExpiresAt() {
return expiresAt;
return expiresAt.orElse(null);
}


@JsonProperty(value = JSON_PROPERTY_EXPIRES_AT, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setExpiresAt(@jakarta.annotation.Nullable String expiresAt) {

public JsonNullable<String> getExpiresAt_JsonNullable() {
return expiresAt;
}

@JsonProperty(JSON_PROPERTY_EXPIRES_AT)
public void setExpiresAt_JsonNullable(JsonNullable<String> expiresAt) {
this.expiresAt = expiresAt;
}

public void setExpiresAt(@jakarta.annotation.Nullable String expiresAt) {
this.expiresAt = JsonNullable.<String>of(expiresAt);
}


public DatastoreAPIKeyResponse key(@jakarta.annotation.Nullable String key) {
this.key = key;
Expand Down Expand Up @@ -285,7 +296,7 @@ public boolean equals(Object o) {
}
DatastoreAPIKeyResponse datastoreAPIKeyResponse = (DatastoreAPIKeyResponse) o;
return Objects.equals(this.createdAt, datastoreAPIKeyResponse.createdAt) &&
Objects.equals(this.expiresAt, datastoreAPIKeyResponse.expiresAt) &&
equalsNullable(this.expiresAt, datastoreAPIKeyResponse.expiresAt) &&
Objects.equals(this.key, datastoreAPIKeyResponse.key) &&
Objects.equals(this.keyType, datastoreAPIKeyResponse.keyType) &&
Objects.equals(this.name, datastoreAPIKeyResponse.name) &&
Expand All @@ -294,9 +305,20 @@ public boolean equals(Object o) {
Objects.equals(this.userId, datastoreAPIKeyResponse.userId);
}

private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
}

@Override
public int hashCode() {
return Objects.hash(createdAt, expiresAt, key, keyType, name, role, uid, userId);
return Objects.hash(createdAt, hashCodeNullable(expiresAt), key, keyType, name, role, uid, userId);
}

private static <T> int hashCodeNullable(JsonNullable<T> a) {
if (a == null) {
return 1;
}
return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
}

@Override
Expand Down
Loading
Loading