537 lines
18 KiB
JSON
537 lines
18 KiB
JSON
{
|
|
"swagger": "2.0",
|
|
"info": {
|
|
"description": "This is a sample server for a hostname service.",
|
|
"title": "Hostname Service API",
|
|
"contact": {
|
|
"name": "Florian Beisel",
|
|
"url": "http://git.beisel.it/florian",
|
|
"email": "florian@beisel.it"
|
|
},
|
|
"license": {
|
|
"name": "Apache 2.0",
|
|
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
|
|
},
|
|
"version": "1"
|
|
},
|
|
"host": "localhost:8080",
|
|
"basePath": "/api/v1",
|
|
"paths": {
|
|
"/api/notebook": {
|
|
"put": {
|
|
"security": [
|
|
{
|
|
"Bearer": []
|
|
}
|
|
],
|
|
"description": "Generates a new hostname for a notebook based on dynamic rules.",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"Manipulate existing Hostnames"
|
|
],
|
|
"summary": "Update hostname for category \"notebook\"",
|
|
"operationId": "update-notebook-hostname",
|
|
"parameters": [
|
|
{
|
|
"description": "Input data to generate hostname",
|
|
"name": "body",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/rules.NotebookRuleInput"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Hostname",
|
|
"schema": {
|
|
"$ref": "#/definitions/models.SimpleHostnameResponse"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"post": {
|
|
"security": [
|
|
{
|
|
"Bearer": []
|
|
}
|
|
],
|
|
"description": "Generates a hostname for a notebook based on dynamic rules.",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"Generating Hostnames"
|
|
],
|
|
"summary": "Generate hostname for category \"notebook\"",
|
|
"operationId": "insert-notebook-hostname",
|
|
"parameters": [
|
|
{
|
|
"description": "Input data to generate hostname",
|
|
"name": "body",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/rules.NotebookRuleInput"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Hostname",
|
|
"schema": {
|
|
"$ref": "#/definitions/models.SimpleHostnameResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/api/server": {
|
|
"put": {
|
|
"security": [
|
|
{
|
|
"Bearer": []
|
|
}
|
|
],
|
|
"description": "Generates a new hostname for a notebook based on dynamic rules.",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"Manipulate existing Hostnames"
|
|
],
|
|
"summary": "Update hostname for category \"notebook\"",
|
|
"operationId": "update-server-hostname",
|
|
"parameters": [
|
|
{
|
|
"description": "Input data to generate hostname",
|
|
"name": "body",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/rules.ServerRuleInput"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Hostname",
|
|
"schema": {
|
|
"$ref": "#/definitions/models.SimpleHostnameResponse"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"post": {
|
|
"security": [
|
|
{
|
|
"Bearer": []
|
|
}
|
|
],
|
|
"description": "Generates a hostname for a notebook based on dynamic rules.",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"Generating Hostnames"
|
|
],
|
|
"summary": "Generate hostname for category \"notebook\"",
|
|
"operationId": "insert-server-hostname",
|
|
"parameters": [
|
|
{
|
|
"description": "Input data to generate hostname",
|
|
"name": "body",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/rules.ServerRuleInput"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Hostname",
|
|
"schema": {
|
|
"$ref": "#/definitions/models.SimpleHostnameResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/hello": {
|
|
"get": {
|
|
"security": [
|
|
{
|
|
"Bearer": []
|
|
}
|
|
],
|
|
"description": "Checks whether the user is successfully authenticated",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"Authentication"
|
|
],
|
|
"summary": "Check your authentication",
|
|
"operationId": "hello",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/login": {
|
|
"post": {
|
|
"description": "Authenticate user and return JWT token",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"Authentication"
|
|
],
|
|
"summary": "User login",
|
|
"parameters": [
|
|
{
|
|
"description": "Login Credentials",
|
|
"name": "loginCredentials",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/models.LoginCredentials"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Successfully authenticated, JWT token returned",
|
|
"schema": {
|
|
"$ref": "#/definitions/models.TokenResponse"
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Invalid request body",
|
|
"schema": {
|
|
"$ref": "#/definitions/models.ErrorResponse"
|
|
}
|
|
},
|
|
"401": {
|
|
"description": "Invalid login credentials",
|
|
"schema": {
|
|
"$ref": "#/definitions/models.ErrorResponse"
|
|
}
|
|
},
|
|
"500": {
|
|
"description": "Internal server error",
|
|
"schema": {
|
|
"$ref": "#/definitions/models.ErrorResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/rules": {
|
|
"get": {
|
|
"security": [
|
|
{
|
|
"Bearer": []
|
|
}
|
|
],
|
|
"description": "Return a list of names of Rules which are known in the RulesRegistry",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"Querying Rules"
|
|
],
|
|
"summary": "Returns a list of available rules",
|
|
"operationId": "get-rules",
|
|
"responses": {}
|
|
}
|
|
},
|
|
"/rules/:rule": {
|
|
"get": {
|
|
"security": [
|
|
{
|
|
"Bearer": []
|
|
}
|
|
],
|
|
"description": "Returns two obea an Input Object and an Output Object\ndescribing the Rules stored values and required parameters",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"Querying Rules"
|
|
],
|
|
"summary": "Returns details about a rule",
|
|
"operationId": "get-rule-details",
|
|
"responses": {
|
|
"200": {
|
|
"description": "Hostname",
|
|
"schema": {
|
|
"$ref": "#/definitions/models.SimpleHostnameResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/{category}": {
|
|
"get": {
|
|
"security": [
|
|
{
|
|
"Bearer": []
|
|
}
|
|
],
|
|
"description": "List all details for a given category",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"Querying Hostnames"
|
|
],
|
|
"summary": "Return a list of hosts and their details filtered by category",
|
|
"operationId": "list-hostnames-by-category",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"description": "Category of the hostname",
|
|
"name": "category",
|
|
"in": "path",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "An array of responses",
|
|
"schema": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/definitions/models.Hostname"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/{category}/{hostname}": {
|
|
"get": {
|
|
"security": [
|
|
{
|
|
"Bearer": []
|
|
}
|
|
],
|
|
"description": "Return details for a single hostname identified by its category",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"Querying Hostnames"
|
|
],
|
|
"summary": "Return a single hostname by Category and Name",
|
|
"operationId": "get-hostname-by-category-and-name",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"description": "Category of the hostname",
|
|
"name": "category",
|
|
"in": "path",
|
|
"required": true
|
|
},
|
|
{
|
|
"type": "string",
|
|
"description": "Category of the hostname",
|
|
"name": "hostname",
|
|
"in": "path",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "A single response object",
|
|
"schema": {
|
|
"$ref": "#/definitions/models.Hostname"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"delete": {
|
|
"security": [
|
|
{
|
|
"Bearer": []
|
|
}
|
|
],
|
|
"description": "List all details for a given category",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"Manipulate existing Hostnames"
|
|
],
|
|
"summary": "Delete a hostname from the database",
|
|
"operationId": "delete-hostnames-by-category-and-name",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"description": "Category of the hostname",
|
|
"name": "category",
|
|
"in": "path",
|
|
"required": true
|
|
},
|
|
{
|
|
"type": "string",
|
|
"description": "Hostname to delete",
|
|
"name": "hostname",
|
|
"in": "path",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Hostname",
|
|
"schema": {
|
|
"$ref": "#/definitions/models.SimpleHostnameResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"definitions": {
|
|
"models.ErrorResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"error": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"models.Hostname": {
|
|
"description": "Model of the Hostname as it is represented in the database",
|
|
"type": "object",
|
|
"properties": {
|
|
"Category": {
|
|
"description": "Category / Rule that was used when generating the hostname",
|
|
"type": "string",
|
|
"example": "notebook"
|
|
},
|
|
"Created_at": {
|
|
"description": "Creation Time of the entry",
|
|
"type": "string",
|
|
"example": "2024-01-16T12:53:59Z"
|
|
},
|
|
"Hostname": {
|
|
"description": "Generated hostname",
|
|
"type": "string",
|
|
"example": "ISEHENNB0009"
|
|
},
|
|
"Id": {
|
|
"description": "Internal ID of the Hostname within the database",
|
|
"type": "integer",
|
|
"example": 25
|
|
},
|
|
"Parameters": {
|
|
"description": "Parameter object of rule specific attributes, see rule.* models",
|
|
"type": "object",
|
|
"additionalProperties": true
|
|
}
|
|
}
|
|
},
|
|
"models.LoginCredentials": {
|
|
"description": "User account information used in the login process with Username and password",
|
|
"type": "object",
|
|
"properties": {
|
|
"Password": {
|
|
"type": "string"
|
|
},
|
|
"Username": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"models.SimpleHostnameResponse": {
|
|
"description": "Model of the Hostname as returned by POST endpoint",
|
|
"type": "object",
|
|
"properties": {
|
|
"Hostname": {
|
|
"description": "Name of the newly generated host",
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"models.TokenResponse": {
|
|
"description": "Model returned after successful login",
|
|
"type": "object",
|
|
"properties": {
|
|
"token": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"rules.NotebookRuleInput": {
|
|
"type": "object",
|
|
"properties": {
|
|
"Location": {
|
|
"type": "string"
|
|
},
|
|
"OrgUnit": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"rules.ServerRuleInput": {
|
|
"type": "object",
|
|
"properties": {
|
|
"Description": {
|
|
"type": "string"
|
|
},
|
|
"ILO": {
|
|
"type": "string"
|
|
},
|
|
"IP": {
|
|
"type": "string"
|
|
},
|
|
"Location": {
|
|
"type": "string"
|
|
},
|
|
"OrgUnit": {
|
|
"type": "string"
|
|
},
|
|
"Responsible": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"securityDefinitions": {
|
|
"Bearer": {
|
|
"description": "Type \"Bearer\" followed by a space and JWT token.",
|
|
"type": "apiKey",
|
|
"name": "Authorization",
|
|
"in": "header"
|
|
}
|
|
}
|
|
} |