Skip to content

Commit

Permalink
merge API to url-shortener
Browse files Browse the repository at this point in the history
  • Loading branch information
cedi committed Mar 8, 2023
1 parent b7eb26d commit 7d59235
Show file tree
Hide file tree
Showing 13 changed files with 1,774 additions and 100 deletions.
375 changes: 375 additions & 0 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,309 @@ const docTemplate = `{
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/api/v1/shortlink/": {
"get": {
"security": [
{
"bearerAuth": []
}
],
"description": "list shortlinks",
"produces": [
"text/plain",
"application/json"
],
"tags": [
"api/v1/"
],
"summary": "list shortlinks",
"responses": {
"200": {
"description": "Success",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/controller.ShortLink"
}
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "integer"
}
},
"404": {
"description": "NotFound",
"schema": {
"type": "integer"
}
},
"500": {
"description": "InternalServerError",
"schema": {
"type": "integer"
}
}
}
}
},
"/api/v1/shortlink/{shortlink}": {
"get": {
"security": [
{
"bearerAuth": []
}
],
"description": "get a shortlink",
"produces": [
"text/plain",
"application/json"
],
"tags": [
"api/v1/"
],
"summary": "get a shortlink",
"parameters": [
{
"type": "string",
"example": "home",
"description": "the shortlink URL part (shortlink id)",
"name": "shortlink",
"in": "path"
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/controller.ShortLink"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "integer"
}
},
"404": {
"description": "NotFound",
"schema": {
"type": "integer"
}
},
"500": {
"description": "InternalServerError",
"schema": {
"type": "integer"
}
}
}
},
"put": {
"security": [
{
"bearerAuth": []
}
],
"description": "update a new shortlink",
"consumes": [
"application/json"
],
"produces": [
"text/plain",
"application/json"
],
"tags": [
"api/v1/"
],
"summary": "update existing shortlink",
"parameters": [
{
"type": "string",
"example": "home",
"description": "the shortlink URL part (shortlink id)",
"name": "shortlink",
"in": "path",
"required": true
},
{
"description": "shortlink spec",
"name": "spec",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1alpha1.ShortLinkSpec"
}
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"type": "integer"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "integer"
}
},
"404": {
"description": "NotFound",
"schema": {
"type": "integer"
}
},
"500": {
"description": "InternalServerError",
"schema": {
"type": "integer"
}
}
}
},
"post": {
"security": [
{
"bearerAuth": []
}
],
"description": "create a new shortlink",
"consumes": [
"application/json"
],
"produces": [
"text/plain",
"application/json"
],
"tags": [
"api/v1/"
],
"summary": "create new shortlink",
"parameters": [
{
"type": "string",
"example": "home",
"description": "the shortlink URL part (shortlink id)",
"name": "shortlink",
"in": "path"
},
{
"description": "shortlink spec",
"name": "spec",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1alpha1.ShortLinkSpec"
}
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"type": "integer"
}
},
"301": {
"description": "MovedPermanently",
"schema": {
"type": "integer"
}
},
"302": {
"description": "Found",
"schema": {
"type": "integer"
}
},
"307": {
"description": "TemporaryRedirect",
"schema": {
"type": "integer"
}
},
"308": {
"description": "PermanentRedirect",
"schema": {
"type": "integer"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "integer"
}
},
"404": {
"description": "NotFound",
"schema": {
"type": "integer"
}
},
"500": {
"description": "InternalServerError",
"schema": {
"type": "integer"
}
}
}
},
"delete": {
"security": [
{
"bearerAuth": []
}
],
"description": "delete shortlink",
"produces": [
"text/plain",
"application/json"
],
"tags": [
"api/v1/"
],
"summary": "delete shortlink",
"parameters": [
{
"type": "string",
"example": "home",
"description": "the shortlink URL part (shortlink id)",
"name": "shortlink",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"type": "integer"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "integer"
}
},
"404": {
"description": "NotFound",
"schema": {
"type": "integer"
}
},
"500": {
"description": "InternalServerError",
"schema": {
"type": "integer"
}
}
}
}
},
"/{shortlink}": {
"get": {
"description": "redirect to target as per configuration of the shortlink",
Expand Down Expand Up @@ -113,6 +416,78 @@ const docTemplate = `{
}
}
}
},
"definitions": {
"controller.ShortLink": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"spec": {
"$ref": "#/definitions/v1alpha1.ShortLinkSpec"
},
"status": {
"$ref": "#/definitions/v1alpha1.ShortLinkStatus"
}
}
},
"v1alpha1.ShortLinkSpec": {
"type": "object",
"properties": {
"after": {
"description": "RedirectAfter specifies after how many seconds to redirect (Default=3)\n+kubebuilder:default:=0\n+kubebuilder:validation:Minimum=0\n+kubebuilder:validation:Maximum=99",
"type": "integer"
},
"code": {
"description": "Code is the URL Code used for the redirection.\nleave on default (307) when using the HTML behavior. However, if you whish to use a HTTP 3xx redirect, set to the appropriate 3xx status code\n+kubebuilder:validation:Enum=200;300;301;302;303;304;305;307;308\n+kubebuilder:default:=307",
"type": "integer",
"enum": [
200,
300,
301,
302,
303,
304,
305,
307,
308
]
},
"owner": {
"description": "Owner is the GitHub user name which created the shortlink\n+kubebuilder:validation:Required",
"type": "string"
},
"owners": {
"description": "Co-Owners are the GitHub user name which can also administrate this shortlink\n+kubebuilder:validation:Optional",
"type": "array",
"items": {
"type": "string"
}
},
"target": {
"description": "Target specifies the target to which we will redirect\n+kubebuilder:validation:Required\n+kubebuilder:validation:MinLength=1",
"type": "string"
}
}
},
"v1alpha1.ShortLinkStatus": {
"type": "object",
"properties": {
"changedby": {
"description": "ChangedBy indicates who (GitHub User) changed the Shortlink last\n+kubebuilder:validation:Optional",
"type": "string"
},
"count": {
"description": "Count represents how often this ShortLink has been called\n+kubebuilder:default:=0\n+kubebuilder:validation:Minimum=0",
"type": "integer"
},
"lastmodified": {
"description": "LastModified is a date-time when the ShortLink was last modified\n+kubebuilder:validation:Format:date-time\n+kubebuilder:validation:Optional",
"type": "string"
}
}
}
}
}`

Expand Down
Loading

0 comments on commit 7d59235

Please sign in to comment.