Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update openapi specs due to recent ServiceConfiguration changes #1218

Merged
merged 5 commits into from
May 9, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

import com.google.common.base.Preconditions;
import java.util.UUID;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.ToString;
import org.jetbrains.annotations.Nullable;

/**
Expand All @@ -32,22 +34,24 @@
* <li>FAILED: indicates that the service couldn't be created.
* </ol>
*
* @param state the creation state of the service.
* @param creationId the creation id of this result, if the state is not {@code FAILED}.
* @param serviceInfo the underlying service info, if the service was created successfully.
* @since 4.0
*/
public record ServiceCreateResult(
@NonNull State state,
@Nullable UUID creationId,
@Nullable ServiceInfoSnapshot serviceInfo
) {
@ToString
@EqualsAndHashCode
// we need to be able to serialize this class and its fields without invoking the getters & setters to respond
// to service creation requests coming from the REST API
@SuppressWarnings("ClassCanBeRecord")
public final class ServiceCreateResult {

/**
* A static create result indicating that the service creation failed.
*/
public static final ServiceCreateResult FAILED = new ServiceCreateResult(State.FAILED, null, null);

private final State state;
private final UUID creationId;
private final ServiceInfoSnapshot serviceInfo;

/**
* Creates a new result instance.
*
Expand All @@ -57,11 +61,19 @@ public record ServiceCreateResult(
* @throws NullPointerException if the given state is null.
* @throws IllegalArgumentException if the creation id is missing or the service info depending on the given state.
*/
public ServiceCreateResult {
private ServiceCreateResult(
@NonNull State state,
@Nullable UUID creationId,
@Nullable ServiceInfoSnapshot serviceInfo
) {
// creation id must be present for deferred and created
Preconditions.checkArgument(state == State.FAILED || creationId != null);
// created services must have a service information present
Preconditions.checkArgument(state != State.CREATED || serviceInfo != null);

this.state = state;
this.creationId = creationId;
this.serviceInfo = serviceInfo;
}

/**
Expand Down Expand Up @@ -94,7 +106,6 @@ public record ServiceCreateResult(
* @return the creation id of this service.
* @throws IllegalStateException if called when the state of this result is {@code FAILED}.
*/
@Override
public @NonNull UUID creationId() {
// we could check for state != State.FAILED as well, but then IJ gives a warning that creationId might be null
Preconditions.checkState(this.creationId != null, "Cannot retrieve creationId for State.FAILED");
Expand All @@ -108,13 +119,22 @@ public record ServiceCreateResult(
* @return the service info of the created service.
* @throws IllegalStateException if called when the state of this result is not {@code CREATED}.
*/
@Override
public @NonNull ServiceInfoSnapshot serviceInfo() {
// we could check for state == State.CREATED as well, but then IJ gives a warning that serviceInfo might be null
Preconditions.checkState(this.serviceInfo != null, "Can only retrieve service info for State.CREATED");
return this.serviceInfo;
}

/**
* Get the state of this service creation. Use this to ensure that the service creation was successful when accessing
* {@link #creationId()} or {@link #serviceInfo()}.
*
* @return the state of this service creation.
*/
public @NonNull State state() {
return this.state;
}

/**
* Represents the state of a service creation.
*
Expand Down
31 changes: 31 additions & 0 deletions modules/rest/src/main/resources/documentation/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4519,6 +4519,15 @@
"type" : "string"
},
"example" : [ "Parameter1", "Parameter2" ]
},
"environmentVariables" : {
"type" : "object",
"additionalProperties" : {
"type" : "string"
},
"example" : {
"MYSQL_PASSWORD" : "PASSWORD"
}
}
}
},
Expand Down Expand Up @@ -4641,6 +4650,9 @@
"$ref" : "#/components/schemas/JsonDocPropertyable"
}, {
"properties" : {
"retryConfiguration" : {
"$ref" : "#/components/schemas/ServiceCreateRetryConfiguration"
},
"serviceId" : {
"$ref" : "#/components/schemas/ServiceId"
},
Expand Down Expand Up @@ -4736,6 +4748,25 @@
}
} ]
},
"ServiceCreateRetryConfiguration" : {
"type" : "object",
"properties" : {
"maxRetries" : {
"type" : "integer",
"example" : 5
},
"backoffStrategy" : {
"type" : "array",
"items" : {
"type" : "integer",
"example" : [ 500, 1500 ]
}
},
"eventReceivers" : {
"type" : "object"
}
}
},
"ServiceCreateResult" : {
"type" : "object",
"properties" : {
Expand Down