Skip to content
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,7 @@ api-project-platform/src/main/java/org/opendevstack/apiservice/projectplatform/a
api-project-platform/src/main/java/org/opendevstack/apiservice/projectplatform/model
api-project/src/main/java/org/opendevstack/apiservice/project/api
api-project/src/main/java/org/opendevstack/apiservice/project/model
api-project-component-v0/src/main/java/org/opendevstack/apiservice/project/api
api-project-component-v0/src/main/java/org/opendevstack/apiservice/project/model
**/.openapi-generator

166 changes: 166 additions & 0 deletions api-project-component-v0/openapi/api-project-component-v0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
openapi: 3.0.3
info:
title: ODS API Server
description: API documentation for ODS (Open DevStack) API Service
contact:
name: ODS Team
version: v0.0.1
servers:
- url: http://{baseurl}/api/pub/v0
variables:
baseurl:
default: localhost:8080
description: Development environment
tags:
- name: ProjectComponents
description: API for managing project components

paths:
/projects/{projectId}/components/:
post:
tags:
- projectComponents
summary: Create a component in a project
operationId: createProjectComponent
description: Retrieves information about a specific component
parameters:
- name: projectId
in: path
required: true
description: Project id
schema:
type: string
requestBody:
description: Component data
content:
application/json:
schema:
$ref: '#/components/schemas/CreateComponentRequest'
responses:
'201':
description: Created
headers:
Location:
schema:
type: string
content:
application/json:
schema:
$ref: '#/components/schemas/CreateComponentResponse'
'400':
description: Bad Request
'401':
$ref: '#/components/responses/UnauthorizedError'
'403':
description: Forbidden
'404':
description: Endpoint not found / Project not found / Product not found
'500':
description: Internal Server Error

/projects/{projectId}/components/{componentId}:
get:
tags:
- projectComponents
summary: Get component information
operationId: getProjectComponent
description: Retrieves information about a specific component
parameters:
- name: projectId
in: path
required: true
description: Project id
schema:
type: string
- name: componentId
in: path
required: true
description: Component id
schema:
type: string
responses:
'200':
description: Component information
content:
application/json:
schema:
$ref: '#/components/schemas/Component'

components:
securitySchemes:
basicAuth:
type: http
scheme: basic
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
responses:
UnauthorizedError:
description: Authentication information is missing or invalid
headers:
WWW_Authenticate:
schema:
type: string
schemas:
Component:
type: object
properties:
id:
type: string
description: Component ID
name:
type: string
description: Name of the component
productDescription:
type: string
description: Description of the product
productName:
type: string
description: Name of the product (e.g. Docker plain)
productId:
type: string
description: Product ID
environment:
type: string
description: Environment (e.g. DEV)
status:
type: string
description: Status of the component (e.g. READY, NOT_READY)
resultTraceback:
type: string
description: Traceback information in case of error
repositoryURL:
type: string
description: URL of the repository (for ODS products)
params:
type: object
description: Additional parameters (key-value pairs)
component-type:
type: string
description: Type of component (ods|awx)
CreateComponentResponse:
type: object
properties:
errorCode:
type: integer
field:
type: string
message:
type: string
location:
type: string
format: url
CreateComponentRequest:
type: object
properties:
name:
type: string
description: component name
productId:
type: string
description: product id
params:
type: object
additionalProperties:
type: string
163 changes: 163 additions & 0 deletions api-project-component-v0/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.opendevstack.apiservice</groupId>
<artifactId>devstack-api-service</artifactId>
<version>0.0.3</version>

</parent>
<artifactId>api-project-component-v0</artifactId>
<name>API Project Components V0</name>
<description>API module for managing EDP project components</description>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>

<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
</dependency>

<dependency>
<groupId>org.opendevstack.apiservice</groupId>
<artifactId>service-projects</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.12.3</version>
</dependency>

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.12.3</version>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.12.3</version>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.6.3</version>
</dependency>

<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>${jackson-databind-nullable.version}</version>
</dependency>

<!-- Test dependencies -->

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.6.3</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-api-project-component-v0</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<generatorName>spring</generatorName>
<output>${project.basedir}</output>
<library>spring-boot</library>
<inputSpec>${project.basedir}/openapi/api-project-component-v0.yaml</inputSpec>
<apiPackage>org.opendevstack.apiservice.project.api</apiPackage>
<modelPackage>org.opendevstack.apiservice.project.model</modelPackage>
<invokerPackage>org.opendevstack.apiservice.project</invokerPackage>
<skipOverwrite>false</skipOverwrite>
<generateApiTests>false</generateApiTests>
<generateModelTests>false</generateModelTests>
<generateApiDocumentation>false</generateApiDocumentation>
<generateModelDocumentation>false</generateModelDocumentation>
<generateSupportingFiles>false</generateSupportingFiles>
<configOptions>
<interfaceOnly>true</interfaceOnly>
<useSpringBoot3>true</useSpringBoot3>
<documentationProvider>springdoc</documentationProvider>
<skipDefaultInterface>true</skipDefaultInterface>
<hideGenerationTimestamp>true</hideGenerationTimestamp>
<useTags>true</useTags>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.opendevstack.apiservice.project.controller;

import org.opendevstack.apiservice.project.model.CreateComponentResponse;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

public class ComponentsResponseFactory {

private ComponentsResponseFactory() {
}

public static CreateComponentResponse error(String projectId) {
CreateComponentResponse response = new CreateComponentResponse();
response.setErrorCode(HttpStatus.INTERNAL_SERVER_ERROR.value());
response.setMessage("Failed to create component for project '" + projectId + "'");
return response;
}

public static CreateComponentResponse entityCreated(String projectId, String componentName) {
CreateComponentResponse response = new CreateComponentResponse();
response.setErrorCode(HttpStatus.CREATED.value());
response.setMessage(componentName + " component created successfully in project " + projectId);
return response;
}
}
Loading
Loading