Implemented pm628 API

Implemented pm628 API

Closes #32 (closed)

Merge request reports

Loading
+55 −23
Changes for src/main/java/org/etsi/osl/tmf/configuration/SwaggerDocumentationConfig.java: 55 added lines, 23 removed lines.
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ public class SwaggerDocumentationConfig {
						.version("4.0.0")
						.license(new License()
								.name("Apache 2.0")
								.url("http://openslice.io")))
								.url("https://osl.etsi.org")))
				.externalDocs(new ExternalDocumentation()
						.description("TMF API Tables")
						.url("https://www.tmforum.org/oda/open-apis/table"));	             
@@ -109,7 +109,7 @@ public class SwaggerDocumentationConfig {
	            		  .description("## TMF API Reference: TMF620 - Product Catalog Management  ### Release : 19.0 - June 2019  Product Catalog API is one of Catalog Management API Family. Product Catalog API goal is to provide a catalog of products.   ### Operations Product Catalog API performs the following operations on the resources : - Retrieve an entity or a collection of entities depending on filter criteria - Partial update of an entity (including updating rules) - Create an entity (including default values and creation rules) - Delete an entity - Manage notification of events")
	                      
		              .version("4.0.0")
		              .license(new License().name("Apache 2.0").url("http://openslice.io")))
		              .license(new License().name("Apache 2.0").url("https://osl.etsi.org")))
					.externalDocs(new ExternalDocumentation()
							.description("TMF API Tables")
							.url("https://www.tmforum.org/oda/open-apis/table"));	     
@@ -148,7 +148,7 @@ public class SwaggerDocumentationConfig {
						.version("1.0.0")
						.license(new License()
								.name("Apache 2.0")
								.url("http://openslice.io")))
								.url("https://osl.etsi.org")))
				.externalDocs(new ExternalDocumentation()
						.description("TMF API Tables")
						.url("https://www.tmforum.org/oda/open-apis/table"));	  	                  
@@ -183,7 +183,7 @@ public class SwaggerDocumentationConfig {
						.version("4.0.0")
						.license(new License()
								.name("Apache 2.0")
								.url("http://openslice.io")))
								.url("https://osl.etsi.org")))
				.externalDocs(new ExternalDocumentation()
						.description("TMF API Tables")
						.url("https://www.tmforum.org/oda/open-apis/table"));	  	                  
@@ -217,7 +217,7 @@ public class SwaggerDocumentationConfig {
						.version("4.0.0")
						.license(new License()
								.name("Apache 2.0")
								.url("http://openslice.io")))
								.url("https://osl.etsi.org")))
				.externalDocs(new ExternalDocumentation()
						.description("TMF API Tables")
						.url("https://www.tmforum.org/oda/open-apis/table"));	  	                  
@@ -255,7 +255,7 @@ public class SwaggerDocumentationConfig {
						.version("4.0.0")
						.license(new License()
								.name("Apache 2.0")
								.url("http://openslice.io")))
								.url("https://osl.etsi.org")))
				.externalDocs(new ExternalDocumentation()
						.description("TMF API Tables")
						.url("https://www.tmforum.org/oda/open-apis/table"));	  	                  
@@ -291,7 +291,7 @@ public class SwaggerDocumentationConfig {
						.version("2.0.0")
						.license(new License()
								.name("Apache 2.0")
								.url("http://openslice.io")))
								.url("https://osl.etsi.org")))
				.externalDocs(new ExternalDocumentation()
						.description("TMF API Tables")
						.url("https://www.tmforum.org/oda/open-apis/table"));	  	                  
@@ -328,7 +328,7 @@ public class SwaggerDocumentationConfig {
						.version("2.0.0")
						.license(new License()
								.name("Apache 2.0")
								.url("http://openslice.io")))
								.url("https://osl.etsi.org")))
				.externalDocs(new ExternalDocumentation()
						.description("TMF API Tables")
						.url("https://www.tmforum.org/oda/open-apis/table"));	  	                  
@@ -366,7 +366,7 @@ public class SwaggerDocumentationConfig {
						.version("4.0.0")
						.license(new License()
								.name("Apache 2.0")
								.url("http://openslice.io")))
								.url("https://osl.etsi.org")))
				.externalDocs(new ExternalDocumentation()
						.description("TMF API Tables")
						.url("https://www.tmforum.org/oda/open-apis/table"));	  	                  
@@ -403,7 +403,7 @@ public class SwaggerDocumentationConfig {
						.version("2.0.0")
						.license(new License()
								.name("Apache 2.0")
								.url("http://openslice.io")))
								.url("https://osl.etsi.org")))
				.externalDocs(new ExternalDocumentation()
						.description("TMF API Tables")
						.url("https://www.tmforum.org/oda/open-apis/table"));	  	                  
@@ -442,7 +442,7 @@ public class SwaggerDocumentationConfig {
						.version("4.0.0")
						.license(new License()
								.name("Apache 2.0")
								.url("http://openslice.io")))
								.url("https://osl.etsi.org")))
				.externalDocs(new ExternalDocumentation()
						.description("TMF API Tables")
						.url("https://www.tmforum.org/oda/open-apis/table"));	  	                  
@@ -479,7 +479,7 @@ public class SwaggerDocumentationConfig {
						.version("4.0.0")
						.license(new License()
								.name("Apache 2.0")
								.url("http://openslice.io")))
								.url("https://osl.etsi.org")))
				.externalDocs(new ExternalDocumentation()
						.description("TMF API Tables")
						.url("https://www.tmforum.org/oda/open-apis/table"));	  	                  
@@ -516,7 +516,7 @@ public class SwaggerDocumentationConfig {
						.version("4.0.0")
						.license(new License()
								.name("Apache 2.0")
								.url("http://openslice.io")))
								.url("https://osl.etsi.org")))
				.externalDocs(new ExternalDocumentation()
						.description("TMF API Tables")
						.url("https://www.tmforum.org/oda/open-apis/table"));	  	                  
@@ -555,7 +555,7 @@ public class SwaggerDocumentationConfig {
//			            .version("3.0.0")
						.license(new License()
								.name("Apache 2.0")
								.url("http://openslice.io")))
								.url("https://osl.etsi.org")))
				.externalDocs(new ExternalDocumentation()
						.description("TMF API Tables")
						.url("https://www.tmforum.org/oda/open-apis/table"));	  	                  
@@ -594,7 +594,7 @@ public class SwaggerDocumentationConfig {
			            .version("4.0.0")
						.license(new License()
								.name("Apache 2.0")
								.url("http://openslice.io")))
								.url("https://osl.etsi.org")))
				.externalDocs(new ExternalDocumentation()
						.description("TMF API Tables")
						.url("https://www.tmforum.org/oda/open-apis/table"));	  	                  
@@ -633,7 +633,7 @@ public class SwaggerDocumentationConfig {
			            .version("1.0.0")
						.license(new License()
								.name("Apache 2.0")
								.url("http://openslice.io")))
								.url("https://osl.etsi.org")))
				.externalDocs(new ExternalDocumentation()
						.description("TMF API Tables")
						.url("https://www.tmforum.org/oda/open-apis/table"));	  	                  
@@ -671,7 +671,7 @@ public class SwaggerDocumentationConfig {
			            .version("4.0.0")
						.license(new License()
								.name("Apache 2.0")
								.url("http://openslice.io")))
								.url("https://osl.etsi.org")))
				.externalDocs(new ExternalDocumentation()
						.description("TMF API Tables")
						.url("https://www.tmforum.org/oda/open-apis/table"));	  	                  
@@ -709,7 +709,7 @@ public class SwaggerDocumentationConfig {
			            .version("4.0.0")
						.license(new License()
								.name("Apache 2.0")
								.url("http://openslice.io")))
								.url("https://osl.etsi.org")))
				.externalDocs(new ExternalDocumentation()
						.description("TMF API Tables")
						.url("https://www.tmforum.org/oda/open-apis/table"));	  	                  
@@ -744,7 +744,7 @@ public class SwaggerDocumentationConfig {
						.version("4.0.0")
						.license(new License()
								.name("Apache 2.0")
								.url("http://openslice.io")))
								.url("https://osl.etsi.org")))
				.externalDocs(new ExternalDocumentation()
						.description("TMF API Tables")
						.url("https://www.tmforum.org/oda/open-apis/table"));
@@ -781,10 +781,10 @@ public class SwaggerDocumentationConfig {
			            .version("4.0.0")
						.license(new License()
								.name("Apache 2.0")
								.url("http://openslice.io")))
								.url("https://osl.etsi.org")))
				.externalDocs(new ExternalDocumentation()
						.description("Openslice")
						.url("http://openslice.io"));	  	                  
						.url("https://osl.etsi.org"));	  	                  
	  }
	
	@Bean
@@ -826,10 +826,10 @@ public class SwaggerDocumentationConfig {
			            .version("1.0.0")
						.license(new License()
								.name("Apache 2.0")
								.url("http://openslice.io")))
								.url("https://osl.etsi.org")))
				.externalDocs(new ExternalDocumentation()
						.description("Openslice")
						.url("http://openslice.io"));	  	                  
						.url("https://osl.etsi.org"));	  	                  
	  }
	
	@Bean
@@ -846,6 +846,38 @@ public class SwaggerDocumentationConfig {
	
	}

	/**
	 * TMF 628 Performance Management
	 * @return
	 */
	@Bean
	public OpenApiCustomizer pm628OpenAPI() {
		return openApi -> openApi
				.specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) 
				.info(new Info().title("TMF628 Performance Management API")
						.description("TMF628 Performance Management API")
						.version("5.0.0")
						.license(new License()
								.name("Apache 2.0")
								.url("https://osl.etsi.org")))
				.externalDocs(new ExternalDocumentation()
						.description("TMF API Tables")
						.url("https://www.tmforum.org/oda/open-apis/table"));	             
	  }
	
    @Bean
    public GroupedOpenApi pm628(){

	  	SpringDocUtils.getConfig().replaceWithClass(java.time.LocalDate.class, java.sql.Date.class);
	  	SpringDocUtils.getConfig().replaceWithClass(java.time.OffsetDateTime.class, java.util.Date.class);
        return GroupedOpenApi.builder()
        		.group("tmf-api-628-PerformanceManagement-v5.0.0")
        		.addOpenApiCustomizer( this.pm628OpenAPI() )
        		.packagesToScan("org.etsi.osl.tmf.pm628.api")
        		.build();

    }
	
	
//	@Bean
//    public SecurityConfiguration security() {
+19 −0
Changes for src/main/java/org/etsi/osl/tmf/pm628/api/ApiUtil.java: 19 added lines, 0 removed lines.
Original line number Diff line number Diff line
package org.etsi.osl.tmf.pm628.api;

import org.springframework.web.context.request.NativeWebRequest;

import jakarta.servlet.http.HttpServletResponse;
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);
        }
    }
}
+273 −0

File added.

Preview size limit exceeded, changes collapsed.

+75 −0
Changes for src/main/java/org/etsi/osl/tmf/pm628/api/DataAccessEndpointApiController.java: 75 added lines, 0 removed lines.
Original line number Diff line number Diff line
package org.etsi.osl.tmf.pm628.api;

import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import jakarta.validation.Valid;
import org.etsi.osl.tmf.pm628.model.DataAccessEndpoint;
import org.etsi.osl.tmf.pm628.reposervices.DataAccessEndpointService;
import org.etsi.osl.tmf.pm628.api.DataAccessEndpointApiController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.context.request.NativeWebRequest;

import javax.annotation.Generated;
import java.util.List;
import java.util.Optional;

@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-05-15T07:30:16.936523289Z[Etc/UTC]", comments = "Generator version: 7.6.0-SNAPSHOT")
@Controller
@RequestMapping("/performance/v5")
public class DataAccessEndpointApiController implements DataAccessEndpointApi {

    private static final Logger log = LoggerFactory.getLogger(DataAccessEndpointApiController.class);

    private final NativeWebRequest request;

    @Autowired
    DataAccessEndpointService dataAccessEndpointService;

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

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

    @PreAuthorize("hasRole('ROLE_USER')")
    @Override
    public ResponseEntity<List<DataAccessEndpoint>> listDataAccessEndpoint(
            @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields,
            @Parameter(name = "offset", description = "Requested index for start of resources to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "offset", required = false) Integer offset,
            @Parameter(name = "limit", description = "Requested number of resources to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "limit", required = false) Integer limit
    ) {
        try {
            return new ResponseEntity<List<DataAccessEndpoint>>(dataAccessEndpointService.findAllDataAccessEndpoints(), HttpStatus.OK);
        } catch (Exception e) {
            log.error("Couldn't serialize response for content type application/json", e);
            return new ResponseEntity<List<DataAccessEndpoint>>(HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }

    @PreAuthorize("hasRole('ROLE_USER')")
    @Override
    public ResponseEntity<DataAccessEndpoint> retrieveDataAccessEndpoint(
            @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id,
            @Parameter(name = "fields", description = "Comma-separated properties to be provided in response", in = ParameterIn.QUERY) @Valid @RequestParam(value = "fields", required = false) String fields
    ) {
        try {
            return new ResponseEntity<DataAccessEndpoint>(dataAccessEndpointService.findDataAccessEndpointByUuid(id), HttpStatus.OK);
        } catch (Exception e) {
            log.error("Couldn't serialize response for content type application/json", e);
            return new ResponseEntity<DataAccessEndpoint>(HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }
}
 No newline at end of file
+134 −0
Changes for src/main/java/org/etsi/osl/tmf/pm628/api/HubApi.java: 134 added lines, 0 removed lines.
Original line number Diff line number Diff line
/**
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.6.0-SNAPSHOT).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */
package org.etsi.osl.tmf.pm628.api;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
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.common.model.Error;
import org.etsi.osl.tmf.pm628.model.Hub;
import org.etsi.osl.tmf.pm628.model.HubFVO;
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.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.context.request.NativeWebRequest;

import javax.annotation.Generated;
import java.util.Optional;

@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-05-15T07:30:16.936523289Z[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 {

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

    /**
     * POST /hub : Create a subscription (hub) to receive Events
     * Sets the communication endpoint to receive Events.
     *
     * @param hubFVO Data containing the callback endpoint to deliver the information (required)
     * @return Notified (status code 201)
     *         or Error (status code 200)
     */
    @Operation(
            operationId = "createHub",
            summary = "Create a subscription (hub) to receive Events",
            description = "Sets the communication endpoint to receive Events.",
            tags = { "events subscription" },
            responses = {
                    @ApiResponse(responseCode = "201", description = "Notified", content = {
                            @Content(mediaType = "application/json", schema = @Schema(implementation = Hub.class))
                    }),
                    @ApiResponse(responseCode = "default", description = "Error", content = {
                            @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class))
                    })
            }
    )
    @RequestMapping(
            method = RequestMethod.POST,
            value = "/hub",
            produces = { "application/json" },
            consumes = { "application/json" }
    )

    default ResponseEntity<Hub> createHub(
            @Parameter(name = "HubFVO", description = "Data containing the callback endpoint to deliver the information", required = true) @Valid @RequestBody HubFVO hubFVO
    ) {
        getRequest().ifPresent(request -> {
            for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
                if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
                    String exampleString = "{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\" }";
                    ApiUtil.setExampleResponse(request, "application/json", exampleString);
                    break;
                }
                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);

    }


    /**
     * DELETE /hub/{id} : Remove a subscription (hub) to receive Events
     *
     *
     * @param id Identifier of the Resource (required)
     * @return Deleted (status code 204)
     *         or Error (status code 200)
     */
    @Operation(
            operationId = "hubDelete",
            summary = "Remove a subscription (hub) to receive Events",
            description = "",
            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> hubDelete(
            @Parameter(name = "id", description = "Identifier of the Resource", required = true, in = ParameterIn.PATH) @PathVariable("id") String id
    ) {
        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
Loading