{ "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": "MIT", "url": "http://git.beisel.it/florian/hostname-service/" }, "version": "1" }, "host": "localhost:8080", "basePath": "/api/v1", "paths": { "/api/notebook": { "put": { "description": "Generates a new hostname for a notebook based on dynamic rules.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Generating 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": { "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" } } } } }, "/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" } } } } }, "/{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" } } } }, "securityDefinitions": { "Bearer": { "description": "Type \"Bearer\" followed by a space and JWT token.", "type": "apiKey", "name": "Authorization", "in": "header" } } }