Commit c10131f7 authored by Labros Papadopoulos's avatar Labros Papadopoulos
Browse files

Upgrade to geographicSiteManagement v5

parent 4f764b1b
Loading
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
package org.etsi.osl.tmf.gsm674.api;

import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.context.request.NativeWebRequest;

import java.io.IOException;

public class ApiUtil {
    public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
        try {
            HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
            res.setCharacterEncoding("UTF-8");
            res.addHeader("Content-Type", contentType);
            res.getWriter().print(example);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;

@Controller
@RequestMapping("/geographicSiteManagement/v4/")
@RequestMapping("/geographicSiteManagement/v5/")
public class GeographicSiteManagementApiController implements GeographicSiteManagementApi{

    private static final String COULD_NOT_SERIALIZE="Couldn't serialize response for content type application/json";
+130 −0
Original line number Diff line number Diff line
package org.etsi.osl.tmf.gsm674.api;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import jakarta.validation.Valid;
import org.etsi.osl.tmf.gsm674.model.EventSubscription;
import org.etsi.osl.tmf.gsm674.model.EventSubscriptionInput;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.NativeWebRequest;

import java.io.IOException;
import java.util.Optional;

@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-04-24T14:24:54.867613034Z[Etc/UTC]", comments = "Generator version: 7.6.0-SNAPSHOT")
@Validated
@Tag(name = "events subscription", description = "Endpoints to register and terminate an Event Listener")
public interface HubApi {
    Logger log = LoggerFactory.getLogger(HubApi.class);
    default Optional<ObjectMapper> getObjectMapper(){
        return Optional.empty();
    }

    default Optional<NativeWebRequest> getRequest() {
        return Optional.empty();
    }

    default Optional<String> getAcceptHeader() {
        return getRequest().map(r -> r.getHeader("Accept"));
    }

    /**
     * POST /hub : Register a listener
     * Sets the communication endpoint address the service instance must use to deliver information about its health state, execution state, failures and metrics.
     *
     * @param eventSubscriptionInput Data containing the callback endpoint to deliver the information (required)
     * @return Notified (status code 201)
     *         or Error (status code 200)
     */
    @Operation(
        operationId = "registerListener",
        summary = "Register a listener",
        description = "Sets the communication endpoint address the service instance must use to deliver information about its health state, execution state, failures and metrics.",
        tags = { "events subscription" },
        responses = {
            @ApiResponse(responseCode = "201", description = "Notified", content = {
                @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = EventSubscription.class)),
                @Content(mediaType = "application/json", schema = @Schema(implementation = EventSubscription.class))
            }),
            @ApiResponse(responseCode = "default", description = "Error", content = {
                @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class)),
                @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class))
            })
        }
    )
    @RequestMapping(
        method = RequestMethod.POST,
        value = "/hub",
        produces = { "application/json;charset=utf-8", "application/json" },
        consumes = { "application/json" }
    )
    
    default ResponseEntity<EventSubscription> registerListener(
        @Parameter(name = "EventSubscriptionInput", description = "Data containing the callback endpoint to deliver the information", required = true) @Valid @RequestBody EventSubscriptionInput eventSubscriptionInput
    ) {
        if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
            if (getAcceptHeader().get().contains("application/json")) {
                try {
                    return new ResponseEntity<>(getObjectMapper().get().readValue("{  \"query\" : \"query\",  \"callback\" : \"callback\",  \"id\" : \"id\"}",EventSubscription.class), HttpStatus.NOT_IMPLEMENTED);
                } catch (IOException e) {
                    log.error("Couldn't serialize response for content type application/json", e);
                    return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
                }
            }
        } else {
            log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated");
        }
        return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);

    }


    /**
     * DELETE /hub/{id} : Unregister a listener
     * Resets the communication endpoint address the service instance must use to deliver information about its health state, execution state, failures and metrics.
     *
     * @param id Identifier of the Service (required)
     * @return Deleted (status code 204)
     *         or Error (status code 200)
     */
    @Operation(
        operationId = "unregisterListener",
        summary = "Unregister a listener",
        description = "Resets the communication endpoint address the service instance must use to deliver information about its health state, execution state, failures and metrics.",
        tags = { "events subscription" },
        responses = {
            @ApiResponse(responseCode = "204", description = "Deleted"),
            @ApiResponse(responseCode = "default", description = "Error", content = {
                @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class))
            })
        }
    )
    @RequestMapping(
        method = RequestMethod.DELETE,
        value = "/hub/{id}",
        produces = { "application/json" }
    )
    
    default ResponseEntity<Void> unregisterListener(
        @Parameter(name = "id", description = "Identifier of the Service", required = true, in = ParameterIn.PATH) @PathVariable("id") String id
    ) {
        if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
        } else {
            log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated");
        }
        return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);

    }

}
+28 −0
Original line number Diff line number Diff line
package org.etsi.osl.tmf.gsm674.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.request.NativeWebRequest;

import java.util.Optional;


@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-04-24T14:24:54.867613034Z[Etc/UTC]", comments = "Generator version: 7.6.0-SNAPSHOT")
@Controller("HubApiController674")
@RequestMapping("/geographicSiteManagement/v5/")
public class HubApiController implements HubApi {

    private final NativeWebRequest request;

    @Autowired
    public HubApiController(NativeWebRequest request) {
        this.request = request;
    }

    @Override
    public Optional<NativeWebRequest> getRequest() {
        return Optional.ofNullable(request);
    }

}
+217 −0
Original line number Diff line number Diff line

package org.etsi.osl.tmf.gsm674.api;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.etsi.osl.tmf.gsm674.model.GeographicSiteAttributeValueChangeEvent;
import org.etsi.osl.tmf.gsm674.model.GeographicSiteCreateEvent;
import org.etsi.osl.tmf.gsm674.model.GeographicSiteDeleteEvent;
import org.etsi.osl.tmf.gsm674.model.GeographicSiteStateChangeEvent;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.NativeWebRequest;

import java.util.Optional;


@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-04-24T14:24:54.867613034Z[Etc/UTC]", comments = "Generator version: 7.6.0-SNAPSHOT")
@Validated
@Tag(name = "notification listener", description = "Notifications for Resource Lifecycle and event notifications")
public interface ListenerApi {
    Logger log = LoggerFactory.getLogger(ListenerApi.class);
    default Optional<NativeWebRequest> getRequest() {
        return Optional.empty();
    }
    default Optional<ObjectMapper> getObjectMapper() {
        return Optional.empty();
    }
    default Optional<String> getAcceptHeader() {
        return getRequest().map(r -> r.getHeader("Accept"));
    }
    /**
     * POST /listener/geographicSiteAttributeValueChangeEvent : Client listener for entity GeographicSiteCreateEvent
     * Example of a client listener for receiving the notification GeographicSiteAttributeValueChangeEvent
     *
     * @param geographicSiteAttributeValueChangeEvent The event data (required)
     * @return Notified (status code 204)
     *         or Error (status code 200)
     */
    @Operation(
        operationId = "geographicSiteAttributeValueChangeEvent",
        summary = "Client listener for entity GeographicSiteCreateEvent",
        description = "Example of a client listener for receiving the notification GeographicSiteAttributeValueChangeEvent",
        tags = { "notification listener" },
        responses = {
            @ApiResponse(responseCode = "204", description = "Notified"),
            @ApiResponse(responseCode = "default", description = "Error", content = {
                @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class))
            })
        }
    )
    @RequestMapping(
        method = RequestMethod.POST,
        value = "/listener/geographicSiteAttributeValueChangeEvent",
        produces = { "application/json" },
        consumes = { "application/json" }
    )
    
    default ResponseEntity<Void> geographicSiteAttributeValueChangeEvent(
        @Parameter(name = "GeographicSiteAttributeValueChangeEvent", description = "The event data", required = true) @Valid @RequestBody GeographicSiteAttributeValueChangeEvent geographicSiteAttributeValueChangeEvent
    ) {
        getRequest().ifPresent(request -> {
            for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
                if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
                    String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }";
                    ApiUtil.setExampleResponse(request, "application/json", exampleString);
                    break;
                }
            }
        });
        return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);

    }


    /**
     * POST /listener/geographicSiteCreateEvent : Client listener for entity GeographicSiteCreateEvent
     * Example of a client listener for receiving the notification GeographicSiteCreateEvent
     *
     * @param geographicSiteCreateEvent The event data (required)
     * @return Notified (status code 204)
     *         or Error (status code 200)
     */
    @Operation(
        operationId = "geographicSiteCreateEvent",
        summary = "Client listener for entity GeographicSiteCreateEvent",
        description = "Example of a client listener for receiving the notification GeographicSiteCreateEvent",
        tags = { "notification listener" },
        responses = {
            @ApiResponse(responseCode = "204", description = "Notified"),
            @ApiResponse(responseCode = "default", description = "Error", content = {
                @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class))
            })
        }
    )
    @RequestMapping(
        method = RequestMethod.POST,
        value = "/listener/geographicSiteCreateEvent",
        produces = { "application/json" },
        consumes = { "application/json" }
    )
    
    default ResponseEntity<Void> geographicSiteCreateEvent(
        @Parameter(name = "GeographicSiteCreateEvent", description = "The event data", required = true) @Valid @RequestBody GeographicSiteCreateEvent geographicSiteCreateEvent
    ) {
        getRequest().ifPresent(request -> {
            for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
                if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
                    String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }";
                    ApiUtil.setExampleResponse(request, "application/json", exampleString);
                    break;
                }
            }
        });
        return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);

    }


    /**
     * POST /listener/geographicSiteDeleteEvent : Client listener for entity GeographicSiteCreateEvent
     * Example of a client listener for receiving the notification GeographicSiteDeleteEvent
     *
     * @param geographicSiteDeleteEvent The event data (required)
     * @return Notified (status code 204)
     *         or Error (status code 200)
     */
    @Operation(
        operationId = "geographicSiteDeleteEvent",
        summary = "Client listener for entity GeographicSiteCreateEvent",
        description = "Example of a client listener for receiving the notification GeographicSiteDeleteEvent",
        tags = { "notification listener" },
        responses = {
            @ApiResponse(responseCode = "204", description = "Notified"),
            @ApiResponse(responseCode = "default", description = "Error", content = {
                @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class))
            })
        }
    )
    @RequestMapping(
        method = RequestMethod.POST,
        value = "/listener/geographicSiteDeleteEvent",
        produces = { "application/json" },
        consumes = { "application/json" }
    )
    
    default ResponseEntity<Void> geographicSiteDeleteEvent(
        @Parameter(name = "GeographicSiteDeleteEvent", description = "The event data", required = true) @Valid @RequestBody GeographicSiteDeleteEvent geographicSiteDeleteEvent
    ) {
        getRequest().ifPresent(request -> {
            for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
                if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
                    String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }";
                    ApiUtil.setExampleResponse(request, "application/json", exampleString);
                    break;
                }
            }
        });
        return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);

    }


    /**
     * POST /listener/geographicSiteStateChangeEvent : Client listener for entity GeographicSiteCreateEvent
     * Example of a client listener for receiving the notification GeographicSiteStateChangeEvent
     *
     * @param geographicSiteStateChangeEvent The event data (required)
     * @return Notified (status code 204)
     *         or Error (status code 200)
     */
    @Operation(
        operationId = "geographicSiteStateChangeEvent",
        summary = "Client listener for entity GeographicSiteCreateEvent",
        description = "Example of a client listener for receiving the notification GeographicSiteStateChangeEvent",
        tags = { "notification listener" },
        responses = {
            @ApiResponse(responseCode = "204", description = "Notified"),
            @ApiResponse(responseCode = "default", description = "Error", content = {
                @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class))
            })
        }
    )
    @RequestMapping(
        method = RequestMethod.POST,
        value = "/listener/geographicSiteStateChangeEvent",
        produces = { "application/json" },
        consumes = { "application/json" }
    )
    
    default ResponseEntity<Void> geographicSiteStateChangeEvent(
        @Parameter(name = "GeographicSiteStateChangeEvent", description = "The event data", required = true) @Valid @RequestBody GeographicSiteStateChangeEvent geographicSiteStateChangeEvent
    ) {
        getRequest().ifPresent(request -> {
            for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
                if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
                    String exampleString = "{ \"reason\" : \"reason\", \"code\" : \"code\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"message\" : \"message\", \"referenceError\" : \"referenceError\", \"status\" : \"status\" }";
                    ApiUtil.setExampleResponse(request, "application/json", exampleString);
                    break;
                }
            }
        });
        return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);

    }

}
Loading