Skip to content

Commit

Permalink
feat: spec gen response command and reply (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
remisultan authored Oct 25, 2024
1 parent 1f3e5f8 commit a4109f5
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<gravitee-alert-api.version>2.0.0</gravitee-alert-api.version>
<gravitee-exchange.version>1.8.2</gravitee-exchange.version>
<gravitee-scoring-api.version>0.3.0</gravitee-scoring-api.version>
<gravitee-spec-gen-api.version>1.0.0</gravitee-spec-gen-api.version>
<gravitee-spec-gen-api.version>1.1.0</gravitee-spec-gen-api.version>
</properties>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright © 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.cockpit.api.command.v1.specgen.response;

import io.gravitee.cockpit.api.command.v1.CockpitCommand;
import io.gravitee.cockpit.api.command.v1.CockpitCommandType;
import io.gravitee.cockpit.api.command.v1.specgen.SpecGenCommandPayload;
import io.gravitee.spec.gen.api.SpecGenResponse;

/**
* @author Rémi SULTAN (remi.sultan at graviteesource.com)
* @author GraviteeSource Team
*/
public final class SpecGenResponseCommand
extends CockpitCommand<SpecGenCommandPayload<SpecGenResponse>> {

public SpecGenResponseCommand() {
super(CockpitCommandType.SPEC_GEN_RESPONSE);
}

public SpecGenResponseCommand(
SpecGenCommandPayload<SpecGenResponse> payload
) {
super(CockpitCommandType.SPEC_GEN_RESPONSE);
this.payload = payload;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright © 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.cockpit.api.command.v1.specgen.response;

import io.gravitee.cockpit.api.command.v1.CockpitCommandType;
import io.gravitee.cockpit.api.command.v1.CockpitReply;
import io.gravitee.cockpit.api.command.v1.specgen.SpecGenReplyPayload;
import io.gravitee.exchange.api.command.CommandStatus;
import io.gravitee.spec.gen.api.SpecGenRequestState;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class SpecGenResponseReply
extends CockpitReply<SpecGenReplyPayload<Void>> {

public SpecGenResponseReply() {
super(CockpitCommandType.SPEC_GEN_RESPONSE);
}

public SpecGenResponseReply(String commandId, CommandStatus commandStatus) {
super(CockpitCommandType.SPEC_GEN_RESPONSE, commandId, commandStatus);
}

public SpecGenResponseReply(String commandId, String errorDetails) {
super(CockpitCommandType.SPEC_GEN_RESPONSE, commandId, CommandStatus.ERROR);
this.errorDetails = errorDetails;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import io.gravitee.cockpit.api.command.v1.scoring.response.ScoringResponseReply;
import io.gravitee.cockpit.api.command.v1.specgen.request.SpecGenRequestCommand;
import io.gravitee.cockpit.api.command.v1.specgen.request.SpecGenRequestReply;
import io.gravitee.cockpit.api.command.v1.specgen.response.SpecGenResponseCommand;
import io.gravitee.cockpit.api.command.v1.specgen.response.SpecGenResponseReply;
import io.gravitee.exchange.api.command.Command;
import io.gravitee.exchange.api.command.Reply;
import io.gravitee.exchange.api.websocket.command.DefaultExchangeSerDe;
Expand Down Expand Up @@ -188,6 +190,10 @@ public class CockpitExchangeSerDe extends DefaultExchangeSerDe {
io.gravitee.cockpit.api.command.v1.CockpitCommandType.SPEC_GEN_REQUEST.name(),
SpecGenRequestCommand.class
);
COMMAND_TYPES.put(
CockpitCommandType.SPEC_GEN_RESPONSE.name(),
SpecGenResponseCommand.class
);

// Legacy
REPLY_TYPES.put(
Expand Down Expand Up @@ -336,6 +342,10 @@ public class CockpitExchangeSerDe extends DefaultExchangeSerDe {
io.gravitee.cockpit.api.command.v1.CockpitCommandType.SPEC_GEN_REQUEST.name(),
SpecGenRequestReply.class
);
REPLY_TYPES.put(
CockpitCommandType.SPEC_GEN_RESPONSE.name(),
SpecGenResponseReply.class
);
}

public CockpitExchangeSerDe(final ObjectMapper objectMapper) {
Expand Down

0 comments on commit a4109f5

Please sign in to comment.