1
0

introduce-hosting-module (#46)

Co-authored-by: Michael Hoennig <michael@hoennig.de>
Reviewed-on: https://dev.hostsharing.net/hostsharing/hs.hsadmin.ng/pulls/46
Reviewed-by: Timotheus Pokorra <timotheus.pokorra@hostsharing.net>
This commit is contained in:
Michael Hoennig
2024-04-23 11:14:48 +02:00
parent 9806bcd78f
commit 66332b6de2
28 changed files with 3308 additions and 5 deletions

View File

@ -0,0 +1,17 @@
openapi-processor-mapping: v2
options:
package-name: net.hostsharing.hsadminng.hs.hosting.generated.api.v1
model-name-suffix: Resource
bean-validation: true
map:
result: org.springframework.http.ResponseEntity
types:
- type: array => java.util.List
- type: string:uuid => java.util.UUID
paths:
/api/hs/hosting/assets/{assetUuid}:
null: org.openapitools.jackson.nullable.JsonNullable

View File

@ -0,0 +1,20 @@
components:
parameters:
currentUser:
name: current-user
in: header
required: true
schema:
type: string
description: Identifying name of the currently logged in user.
assumedRoles:
name: assumed-roles
in: header
required: false
schema:
type: string
description: Semicolon-separated list of roles to assume. The current user needs to have the right to assume these roles.

View File

@ -0,0 +1,40 @@
components:
responses:
NotFound:
description: The specified was not found.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
Unauthorized:
description: The current user is unknown or not authorized.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
Forbidden:
description: The current user or none of the assumed or roles is granted access to the resource.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
Conflict:
description: The request could not be completed due to a conflict with the current state of the target resource.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
schemas:
Error:
type: object
properties:
code:
type: string
message:
type: string
required:
- code
- message

View File

@ -0,0 +1,97 @@
components:
schemas:
HsHostingAssetType:
type: string
enum:
- CLOUD_SERVER
- MANAGED_SERVER
- MANAGED_WEBSPACE
- UNIX_USER
- DOMAIN_SETUP
- EMAIL_ALIAS
- EMAIL_ADDRESS
- PGSQL_USER
- PGSQL_DATABASE
- MARIADB_USER
- MARIADB_DATABASE
HsHostingAsset:
type: object
properties:
uuid:
type: string
format: uuid
type:
$ref: '#/components/schemas/HsHostingAssetType'
identifier:
type: string
caption:
type: string
config:
$ref: '#/components/schemas/HsHostingAssetConfiguration'
required:
- type
- ídentifier
- uuid
- config
HsHostingAssetPatch:
type: object
properties:
caption:
type: string
nullable: true
config:
$ref: '#/components/schemas/HsHostingAssetConfiguration'
HsHostingAssetInsert:
type: object
properties:
bookingItemUuid:
type: string
format: uuid
nullable: false
type:
$ref: '#/components/schemas/HsHostingAssetType'
identifier:
type: string
minLength: 3
maxLength: 80
nullable: false
caption:
type: string
minLength: 3
maxLength: 80
nullable: false
config:
$ref: '#/components/schemas/HsHostingAssetConfiguration'
required:
- type
- identifier
- caption
- debitorUuid
- config
additionalProperties: false
HsHostingAssetConfiguration:
# forces generating a java.lang.Object containing a Map, instead of class AssetConfiguration
anyOf:
- type: object
properties:
CPU:
type: integer
minimum: 1
maximum: 16
SSD:
type: integer
minimum: 16
maximum: 4096
HDD:
type: integer
minimum: 16
maximum: 4096
additionalProperties: true

View File

@ -0,0 +1,83 @@
get:
tags:
- hs-hosting-assets
description: 'Fetch a single managed asset by its uuid, if visible for the current subject.'
operationId: getAssetByUuid
parameters:
- $ref: 'auth.yaml#/components/parameters/currentUser'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
- name: assetUuid
in: path
required: true
schema:
type: string
format: uuid
description: UUID of the hosting asset to fetch.
responses:
"200":
description: OK
content:
'application/json':
schema:
$ref: 'hs-hosting-asset-schemas.yaml#/components/schemas/HsHostingAsset'
"401":
$ref: 'error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: 'error-responses.yaml#/components/responses/Forbidden'
patch:
tags:
- hs-hosting-assets
description: 'Updates a single hosting asset identified by its uuid, if permitted for the current subject.'
operationId: patchAsset
parameters:
- $ref: 'auth.yaml#/components/parameters/currentUser'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
- name: assetUuid
in: path
required: true
schema:
type: string
format: uuid
requestBody:
content:
'application/json':
schema:
$ref: 'hs-hosting-asset-schemas.yaml#/components/schemas/HsHostingAssetPatch'
responses:
"200":
description: OK
content:
'application/json':
schema:
$ref: 'hs-hosting-asset-schemas.yaml#/components/schemas/HsHostingAsset'
"401":
$ref: 'error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: 'error-responses.yaml#/components/responses/Forbidden'
delete:
tags:
- hs-hosting-assets
description: 'Delete a single hosting asset identified by its uuid, if permitted for the current subject.'
operationId: deleteAssetUuid
parameters:
- $ref: 'auth.yaml#/components/parameters/currentUser'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
- name: assetUuid
in: path
required: true
schema:
type: string
format: uuid
description: UUID of the hosting asset to delete.
responses:
"204":
description: No Content
"401":
$ref: 'error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: 'error-responses.yaml#/components/responses/Forbidden'
"404":
$ref: 'error-responses.yaml#/components/responses/NotFound'

View File

@ -0,0 +1,58 @@
get:
summary: Returns a list of all hosting assets for a specified debitor.
description: Returns the list of all hosting assets for a debitor which are visible to the current user or any of it's assumed roles.
tags:
- hs-hosting-assets
operationId: listAssetsByDebitorUuid
parameters:
- $ref: 'auth.yaml#/components/parameters/currentUser'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
- name: debitorUuid
in: query
required: true
schema:
type: string
format: uuid
description: The UUID of the debitor, whose hosting assets are to be listed.
responses:
"200":
description: OK
content:
'application/json':
schema:
type: array
items:
$ref: 'hs-hosting-asset-schemas.yaml#/components/schemas/HsHostingAsset'
"401":
$ref: 'error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: 'error-responses.yaml#/components/responses/Forbidden'
post:
summary: Adds a new hosting asset.
tags:
- hs-hosting-assets
operationId: addAsset
parameters:
- $ref: 'auth.yaml#/components/parameters/currentUser'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
requestBody:
description: A JSON object describing the new hosting asset.
required: true
content:
application/json:
schema:
$ref: 'hs-hosting-asset-schemas.yaml#/components/schemas/HsHostingAssetInsert'
responses:
"201":
description: Created
content:
'application/json':
schema:
$ref: 'hs-hosting-asset-schemas.yaml#/components/schemas/HsHostingAsset'
"401":
$ref: 'error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: 'error-responses.yaml#/components/responses/Forbidden'
"409":
$ref: 'error-responses.yaml#/components/responses/Conflict'

View File

@ -0,0 +1,17 @@
openapi: 3.0.3
info:
title: Hostsharing hsadmin-ng API
version: v0
servers:
- url: http://localhost:8080
description: Local development default URL.
paths:
# Items
/api/hs/hosting/assets:
$ref: "hs-hosting-assets.yaml"
/api/hs/hosting/assets/{assetUuid}:
$ref: "hs-hosting-assets-with-uuid.yaml"