Compare commits
3 Commits
feature/ad
...
demo-alpr
| Author | SHA1 | Date | |
|---|---|---|---|
| fd92c76003 | |||
| e4f0f6f4ca | |||
| cf92b46ce6 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
swagger/
|
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
ARG KUBERNETES_HOST=${KUBERNETES_HOST:-"127.0.0.1"}
|
||||||
|
|
||||||
FROM golang:alpine AS deps
|
FROM golang:alpine AS deps
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -28,7 +30,7 @@ RUN export CGO_ENABLED=0 && \
|
|||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN sed -i '/replace/d' go.mod
|
RUN sed -i '/replace/d' go.mod
|
||||||
RUN if [ ! -f swagger/index.html ]; then timeout 15 bee run -gendoc=true -downdoc=true; fi
|
RUN if [ ! -f swagger/index.html ]; then timeout 15 bee run --gendoc=true --downdoc=true; fi
|
||||||
RUN bee generate routers
|
RUN bee generate routers
|
||||||
RUN bee generate docs
|
RUN bee generate docs
|
||||||
RUN bee pack
|
RUN bee pack
|
||||||
@@ -39,6 +41,8 @@ RUN sed -i 's/http:\/\/127.0.0.1:8080\/swagger\/swagger.json/swagger.json/g' /ap
|
|||||||
|
|
||||||
FROM golang:alpine
|
FROM golang:alpine
|
||||||
|
|
||||||
|
ENV KUBERNETES_SERVICE_HOST=$KUBERNETES_HOST
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=builder /app/extracted/oc-datacenter /usr/bin/
|
COPY --from=builder /app/extracted/oc-datacenter /usr/bin/
|
||||||
COPY --from=builder /app/extracted/swagger /app/swagger
|
COPY --from=builder /app/extracted/swagger /app/swagger
|
||||||
|
|||||||
@@ -10,13 +10,10 @@ import (
|
|||||||
"slices"
|
"slices"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
oclib "cloud.o-forge.io/core/oc-lib"
|
|
||||||
|
|
||||||
beego "github.com/beego/beego/v2/server/web"
|
beego "github.com/beego/beego/v2/server/web"
|
||||||
jwt "github.com/golang-jwt/jwt/v5"
|
jwt "github.com/golang-jwt/jwt/v5"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type KubeInfo struct {
|
type KubeInfo struct {
|
||||||
@@ -142,12 +139,6 @@ func (c *AdmiraltyController) CreateSource() {
|
|||||||
|
|
||||||
res, err := serv.CreateAdmiraltySource(c.Ctx.Request.Context(),execution)
|
res, err := serv.CreateAdmiraltySource(c.Ctx.Request.Context(),execution)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if apierrors.IsAlreadyExists(err) {
|
|
||||||
c.Ctx.Output.SetStatus(409)
|
|
||||||
c.Data["json"] = map[string]string{"info" : "A source already exists for this namespace : " + execution}
|
|
||||||
c.ServeJSON()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// change code to 500
|
// change code to 500
|
||||||
c.Ctx.Output.SetStatus(500)
|
c.Ctx.Output.SetStatus(500)
|
||||||
c.Data["json"] = map[string]string{"error": err.Error()}
|
c.Data["json"] = map[string]string{"error": err.Error()}
|
||||||
@@ -324,6 +315,7 @@ func (c *AdmiraltyController) CreateKubeSecret() {
|
|||||||
// @router /node/:execution [get]
|
// @router /node/:execution [get]
|
||||||
func (c *AdmiraltyController) GetNodeReady(){
|
func (c *AdmiraltyController) GetNodeReady(){
|
||||||
var secret v1.Secret
|
var secret v1.Secret
|
||||||
|
|
||||||
execution := c.Ctx.Input.Param(":execution")
|
execution := c.Ctx.Input.Param(":execution")
|
||||||
|
|
||||||
|
|
||||||
@@ -347,14 +339,12 @@ func (c *AdmiraltyController) GetNodeReady(){
|
|||||||
if node == nil {
|
if node == nil {
|
||||||
c.Ctx.Output.SetStatus(404)
|
c.Ctx.Output.SetStatus(404)
|
||||||
c.Data["json"] = map[string]string{
|
c.Data["json"] = map[string]string{
|
||||||
"node" : "the node for " + execution + " can't be found, make sure both target and source resources are set up on local and remote hosts",
|
"error" : "the node for " + execution + " can't be found, make sure both target and source resources are set up on local and remote hosts",
|
||||||
}
|
}
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp, err := serv.GetKubeconfigSecret(c.Ctx.Request.Context(),execution)
|
resp, err := serv.GetKubeconfigSecret(c.Ctx.Request.Context(),execution)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// change code to 500
|
// change code to 500
|
||||||
@@ -370,6 +360,7 @@ func (c *AdmiraltyController) GetNodeReady(){
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Extract JWT token RS265 encoded
|
// Extract JWT token RS265 encoded
|
||||||
var editedKubeconfig map[string]interface{}
|
var editedKubeconfig map[string]interface{}
|
||||||
json.Unmarshal(resp,&secret)
|
json.Unmarshal(resp,&secret)
|
||||||
@@ -402,15 +393,14 @@ func (c *AdmiraltyController) GetNodeReady(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if *isExpired {
|
if *isExpired {
|
||||||
c.Data["json"] = map[string]interface{}{
|
c.Data["json"] = map[string]string{
|
||||||
"token" : "token in the secret is expired and must be regenerated",
|
"token" : "token in the secret is expired and must be regenerated",
|
||||||
"node": node,
|
|
||||||
}
|
}
|
||||||
c.Ctx.Output.SetStatus(410)
|
c.Ctx.Output.SetStatus(410)
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Data["json"] = map[string]interface{}{"node": node,"token": true}
|
c.Data["json"] = map[string]bool{"ok": true}
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -436,8 +426,6 @@ func retrieveTokenFromKonfig(editedKubeconfig map[string]interface{}) (string,er
|
|||||||
}
|
}
|
||||||
|
|
||||||
func isTokenExpired(token string) (*bool, error){
|
func isTokenExpired(token string) (*bool, error){
|
||||||
logger := oclib.GetLogger()
|
|
||||||
|
|
||||||
t, _, err := new(jwt.Parser).ParseUnverified(token, jwt.MapClaims{})
|
t, _, err := new(jwt.Parser).ParseUnverified(token, jwt.MapClaims{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("couldn't decode token")
|
fmt.Println("couldn't decode token")
|
||||||
@@ -449,11 +437,7 @@ func isTokenExpired(token string) (*bool, error){
|
|||||||
fmt.Println("Error while checking token's expiration time")
|
fmt.Println("Error while checking token's expiration time")
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
fmt.Println("Expiration date : " + expiration.UTC().Format("2006-01-02T15:04:05"))
|
||||||
logger.Debug().Msg("Expiration date : " + expiration.UTC().Format("2006-01-02T15:04:05"))
|
|
||||||
logger.Debug().Msg(fmt.Sprint("Now : ", time.Now().Unix()))
|
|
||||||
logger.Debug().Msg(fmt.Sprint("Token : ", expiration.Unix()))
|
|
||||||
|
|
||||||
|
|
||||||
expired := expiration.Unix() < time.Now().Unix()
|
expired := expiration.Unix() < time.Now().Unix()
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"oc-datacenter/infrastructure"
|
"oc-datacenter/infrastructure"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
oclib "cloud.o-forge.io/core/oc-lib"
|
oclib "cloud.o-forge.io/core/oc-lib"
|
||||||
@@ -247,19 +246,11 @@ func (o *BookingController) Post() {
|
|||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := o.createNamespace(resp.ExecutionsID); err != nil {
|
|
||||||
if strings.Contains(err.Error(), "already exists") {
|
/*if err := o.createNamespace(resp.ExecutionsID); err != nil {
|
||||||
err = nil
|
fmt.Println(err.Error())
|
||||||
} else {
|
}*/
|
||||||
o.Data["json"] = map[string]interface{}{
|
|
||||||
"data": nil,
|
|
||||||
"code": 500,
|
|
||||||
"error": err.Error(),
|
|
||||||
}
|
|
||||||
o.ServeJSON()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
o.Data["json"] = map[string]interface{}{
|
o.Data["json"] = map[string]interface{}{
|
||||||
"data": []interface{}{b},
|
"data": []interface{}{b},
|
||||||
"code": 200,
|
"code": 200,
|
||||||
|
|||||||
@@ -3,8 +3,5 @@
|
|||||||
"NATS_URL": "nats://localhost:4222",
|
"NATS_URL": "nats://localhost:4222",
|
||||||
"MONGO_DATABASE": "DC_myDC",
|
"MONGO_DATABASE": "DC_myDC",
|
||||||
"KUBERNETES_SERVICE_HOST": "172.16.0.183",
|
"KUBERNETES_SERVICE_HOST": "172.16.0.183",
|
||||||
"port": "8092",
|
"port": "8092"
|
||||||
"KUBE_CA": "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJlRENDQVIyZ0F3SUJBZ0lCQURBS0JnZ3Foa2pPUFFRREFqQWpNU0V3SHdZRFZRUUREQmhyTTNNdGMyVnkKZG1WeUxXTmhRREUzTXpnNE5UazJNVFl3SGhjTk1qVXdNakEyTVRZek16TTJXaGNOTXpVd01qQTBNVFl6TXpNMgpXakFqTVNFd0h3WURWUVFEREJock0zTXRjMlZ5ZG1WeUxXTmhRREUzTXpnNE5UazJNVFl3V1RBVEJnY3Foa2pPClBRSUJCZ2dxaGtqT1BRTUJCd05DQUFSbi9jVmNUb1orekZUdWZSL29qbG5JMnVpZXJYeTkxcWhxYWpHdWVobXYKV1A4NVQ1dXpkcE1rcFhrNnB5bTlFU0RlRjk1WDFkeTJqdjVFR3paZzZ2WWtvMEl3UURBT0JnTlZIUThCQWY4RQpCQU1DQXFRd0R3WURWUjBUQVFIL0JBVXdBd0V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TZRPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo="
|
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,9 @@ version: '3.4'
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
oc-datacenter:
|
oc-datacenter:
|
||||||
|
env_file:
|
||||||
|
- path: ./env.env
|
||||||
|
required: false
|
||||||
environment:
|
environment:
|
||||||
- MONGO_DATABASE=DC_myDC
|
- MONGO_DATABASE=DC_myDC
|
||||||
image: 'oc-datacenter:latest'
|
image: 'oc-datacenter:latest'
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
{
|
{
|
||||||
"MONGO_URL":"mongodb://mongo:27017/",
|
"MONGO_URL":"mongodb://mongo:27017/",
|
||||||
"NATS_URL":"nats://nats:4222",
|
"NATS_URL":"nats://nats:4222",
|
||||||
"MONGO_DATABASE":"DC_myDC",
|
"MONGO_DATABASE":"DC_myDC"
|
||||||
"KUBERNETES_SERVICE_HOST" : "172.16.0.181",
|
|
||||||
"KUBE_CA" : "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJlRENDQVIyZ0F3SUJBZ0lCQURBS0JnZ3Foa2pPUFFRREFqQWpNU0V3SHdZRFZRUUREQmhyTTNNdGMyVnkKZG1WeUxXTmhRREUzTXpnNE5UazJNVFl3SGhjTk1qVXdNakEyTVRZek16TTJXaGNOTXpVd01qQTBNVFl6TXpNMgpXakFqTVNFd0h3WURWUVFEREJock0zTXRjMlZ5ZG1WeUxXTmhRREUzTXpnNE5UazJNVFl3V1RBVEJnY3Foa2pPClBRSUJCZ2dxaGtqT1BRTUJCd05DQUFSbi9jVmNUb1orekZUdWZSL29qbG5JMnVpZXJYeTkxcWhxYWpHdWVobXYKV1A4NVQ1dXpkcE1rcFhrNnB5bTlFU0RlRjk1WDFkeTJqdjVFR3paZzZ2WWtvMEl3UURBT0JnTlZIUThCQWY4RQpCQU1DQXFRd0R3WURWUjBUQVFIL0JBVXdBd0VCL3p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RBbFVXUW5FakxMdlpDWlVaYTlzTlhKOUVtWWt5S0dtQWR2TE9FbUVrbzBJd1FEQU9CZ05WSFE4QkFmOEUKQkFNQ0FxUXdEd1lEVlIwVEFRSC9CQVV3QXdFQi96QWRCZ05WSFE0RUZnUVVGU3ZmR2RBdGFVSzAwVWRIaW5jUgo1SStNOVNBd0NnWUlLb1pJemowRUF3SURTUUF3UmdJaEFMY2xtQnR4TnpSVlBvV2hoVEVKSkM1Z3VNSGsvcFZpCjFvYXJ2UVJxTWRKcUFpRUEyR1dNTzlhZFFYTEQwbFZKdHZMVkc1M3I0M0lxMHpEUUQwbTExMVZyL1MwPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg=="
|
||||||
|
KUBE_DATA="LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSUVkSTRZN3lRU1ZwRGNrblhsQmJEaXBWZHRMWEVsYVBkN3VBZHdBWFFya2xvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFOHpzQk1VOGxvdmJuN0RSQXloNEhWYUVBU2Y5bTV2Y3BFTU9SdlBUeGVrQnUrTVNLK0NBMAphSzJmUlY2V0VVYU4xL2pNQTZnekJIRGVaMmRjZVFaUFRBPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo="
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
package infrastructure
|
package infrastructure
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html/template"
|
||||||
"oc-datacenter/conf"
|
"oc-datacenter/conf"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -14,42 +16,14 @@ import (
|
|||||||
rbacv1 "k8s.io/api/rbac/v1"
|
rbacv1 "k8s.io/api/rbac/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
|
||||||
apply "k8s.io/client-go/applyconfigurations/core/v1"
|
|
||||||
"k8s.io/client-go/dynamic"
|
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
var gvrSources = schema.GroupVersionResource{Group: "multicluster.admiralty.io", Version: "v1alpha1", Resource: "sources"}
|
|
||||||
var gvrTargets = schema.GroupVersionResource{Group: "multicluster.admiralty.io", Version: "v1alpha1", Resource: "targets"}
|
|
||||||
|
|
||||||
type KubernetesService struct {
|
type KubernetesService struct {
|
||||||
Set *kubernetes.Clientset
|
Set *kubernetes.Clientset
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDynamicClient() (*dynamic.DynamicClient, error) {
|
|
||||||
config := &rest.Config{
|
|
||||||
Host: conf.GetConfig().KubeHost + ":" + conf.GetConfig().KubePort,
|
|
||||||
TLSClientConfig: rest.TLSClientConfig{
|
|
||||||
CAData: []byte(conf.GetConfig().KubeCA),
|
|
||||||
CertData: []byte(conf.GetConfig().KubeCert),
|
|
||||||
KeyData: []byte(conf.GetConfig().KubeData),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
dynamicClient, err := dynamic.NewForConfig(config)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.New("Error creating Dynamic client: " + err.Error())
|
|
||||||
}
|
|
||||||
if dynamicClient == nil {
|
|
||||||
return nil, errors.New("Error creating Dynamic client: dynamicClient is nil")
|
|
||||||
}
|
|
||||||
|
|
||||||
return dynamicClient, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewKubernetesService() (Infrastructure, error) {
|
func NewKubernetesService() (Infrastructure, error) {
|
||||||
config := &rest.Config{
|
config := &rest.Config{
|
||||||
Host: conf.GetConfig().KubeHost + ":" + conf.GetConfig().KubePort,
|
Host: conf.GetConfig().KubeHost + ":" + conf.GetConfig().KubePort,
|
||||||
@@ -59,7 +33,6 @@ func NewKubernetesService() (Infrastructure, error) {
|
|||||||
KeyData: []byte(conf.GetConfig().KubeData),
|
KeyData: []byte(conf.GetConfig().KubeData),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create clientset
|
// Create clientset
|
||||||
clientset, err := kubernetes.NewForConfig(config)
|
clientset, err := kubernetes.NewForConfig(config)
|
||||||
fmt.Println("NewForConfig", clientset, err)
|
fmt.Println("NewForConfig", clientset, err)
|
||||||
@@ -70,7 +43,6 @@ func NewKubernetesService() (Infrastructure, error) {
|
|||||||
return nil, errors.New("Error creating Kubernetes client: clientset is nil")
|
return nil, errors.New("Error creating Kubernetes client: clientset is nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return &KubernetesService{
|
return &KubernetesService{
|
||||||
Set: clientset,
|
Set: clientset,
|
||||||
}, nil
|
}, nil
|
||||||
@@ -110,9 +82,6 @@ func (k *KubernetesService) CreateNamespace(ctx context.Context, ns string) erro
|
|||||||
namespace := &v1.Namespace{
|
namespace := &v1.Namespace{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: ns,
|
Name: ns,
|
||||||
Labels: map[string]string{
|
|
||||||
"multicluster-scheduler":"enabled",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
// Create the namespace
|
// Create the namespace
|
||||||
@@ -226,8 +195,6 @@ func (k *KubernetesService) GenerateToken(ctx context.Context, ns string, durati
|
|||||||
return token.Status.Token, nil
|
return token.Status.Token, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Needs refactoring :
|
// Needs refactoring :
|
||||||
// - Retrieving the metada (in a method that Unmarshall the part of the json in a metadata object)
|
// - Retrieving the metada (in a method that Unmarshall the part of the json in a metadata object)
|
||||||
func (k *KubernetesService) GetTargets(ctx context.Context) ([]string, error) {
|
func (k *KubernetesService) GetTargets(ctx context.Context) ([]string, error) {
|
||||||
@@ -294,30 +261,33 @@ func (k *KubernetesService) CreateAdmiraltyTarget(context context.Context,execut
|
|||||||
return nil, nil // Maybe we could create a wrapper for errors and add more info to have
|
return nil, nil // Maybe we could create a wrapper for errors and add more info to have
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var targetManifest string
|
||||||
target := map[string]interface{}{
|
var tpl bytes.Buffer
|
||||||
"apiVersion": "multicluster.admiralty.io/v1alpha1",
|
tmpl, err := template.New("target").
|
||||||
"kind": "Target",
|
Parse("{\"apiVersion\": \"multicluster.admiralty.io/v1alpha1\", \"kind\": \"Target\", \"metadata\": {\"name\": \"target-{{.ExecutionId}}\"}, \"spec\": { \"kubeconfigSecret\" :{\"name\": \"kube-secret-{{.ExecutionId}}\"}} }")
|
||||||
"metadata": map[string]interface{}{
|
|
||||||
"name": "target-"+executionId,
|
|
||||||
"namespace": executionId,
|
|
||||||
},
|
|
||||||
"spec": map[string]interface{}{
|
|
||||||
"kubeconfigSecret": map[string]string{
|
|
||||||
"name" : "kube-secret-"+executionId,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
res, err := dynamicClientApply(executionId, "target", gvrTargets, context, target)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New("Error when trying to apply Source definition :" + err.Error())
|
fmt.Println("Error creating the template for the target Manifest")
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return res, nil
|
err = tmpl.Execute(&tpl, map[string]string{"ExecutionId": executionId})
|
||||||
|
targetManifest = tpl.String()
|
||||||
|
resp, err := postCDRapiKube(
|
||||||
|
*k.Set,
|
||||||
|
context,
|
||||||
|
"/apis/multicluster.admiralty.io/v1alpha1/namespaces/"+executionId+"/targets",
|
||||||
|
[]byte(targetManifest),
|
||||||
|
map[string]string{"fieldManager": "kubectl-client-side-apply"},
|
||||||
|
map[string]string{"fieldValidation": "Strict"},
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error trying to create a Source on remote cluster : ", err, " : ", resp)
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Admiralty Source allows a cluster to receive pods from a remote cluster
|
// Admiralty Source allows a cluster to receive pods from a remote cluster
|
||||||
//
|
//
|
||||||
@@ -328,26 +298,34 @@ func (k *KubernetesService) CreateAdmiraltyTarget(context context.Context,execut
|
|||||||
// to rather contact the oc-datacenter from the remote cluster to create the source
|
// to rather contact the oc-datacenter from the remote cluster to create the source
|
||||||
// locally and retrieve the token for the serviceAccount
|
// locally and retrieve the token for the serviceAccount
|
||||||
func (k *KubernetesService) CreateAdmiraltySource(context context.Context, executionId string) ([]byte, error) {
|
func (k *KubernetesService) CreateAdmiraltySource(context context.Context, executionId string) ([]byte, error) {
|
||||||
|
var sourceManifest string
|
||||||
source := map[string]interface{}{
|
var tpl bytes.Buffer
|
||||||
"apiVersion": "multicluster.admiralty.io/v1alpha1",
|
tmpl, err := template.New("source").
|
||||||
"kind": "Source",
|
Parse("{\"apiVersion\": \"multicluster.admiralty.io/v1alpha1\", \"kind\": \"Source\", \"metadata\": {\"name\": \"source-{{.ExecutionId}}\"}, \"spec\": {\"serviceAccountName\": \"sa-{{.ExecutionId}}\"} }")
|
||||||
"metadata": map[string]interface{}{
|
|
||||||
"name": "source-"+executionId,
|
|
||||||
"namespace": executionId,
|
|
||||||
},
|
|
||||||
"spec": map[string]interface{}{
|
|
||||||
"serviceAccountName": "sa-"+executionId,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
res, err := dynamicClientApply(executionId, "source",gvrSources, context, source)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New("Error when trying to apply Source definition :" + err.Error())
|
fmt.Println("Error creating the template for the source Manifest")
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return res, nil
|
err = tmpl.Execute(&tpl, map[string]string{"ExecutionId": executionId})
|
||||||
|
sourceManifest = tpl.String()
|
||||||
|
|
||||||
|
resp, err := postCDRapiKube(
|
||||||
|
*k.Set,
|
||||||
|
context,
|
||||||
|
"/apis/multicluster.admiralty.io/v1alpha1/namespaces/"+executionId+"/sources",
|
||||||
|
[]byte(sourceManifest),
|
||||||
|
map[string]string{"fieldManager": "kubectl-client-side-apply"},
|
||||||
|
map[string]string{"fieldValidation": "Strict"},
|
||||||
|
)
|
||||||
|
|
||||||
|
// We can add more info to the log with the content of resp if not nil
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error trying to create a Source on remote cluster : ", err, " : ", resp)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a secret from a kubeconfing. Use it to create the secret binded to an Admiralty
|
// Create a secret from a kubeconfing. Use it to create the secret binded to an Admiralty
|
||||||
@@ -361,37 +339,32 @@ func (k *KubernetesService) CreateKubeconfigSecret(context context.Context,kubec
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
secretApplyConfig := apply.Secret("kube-secret-" + executionId,
|
secretManifest := &v1.Secret{
|
||||||
executionId).
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
WithData(map[string][]byte{
|
Name: "kube-secret-" + executionId,
|
||||||
|
Namespace: executionId,
|
||||||
|
},
|
||||||
|
Data: map[string][]byte{
|
||||||
"config": config,
|
"config": config,
|
||||||
},
|
},
|
||||||
)
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// exists, err := k.GetKubeconfigSecret(context,executionId)
|
|
||||||
// if err != nil {
|
|
||||||
// fmt.Println("Error verifying if kube secret exists in namespace ", executionId)
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// if exists != nil {
|
|
||||||
// fmt.Println("kube-secret already exists in namespace", executionId)
|
|
||||||
// fmt.Println("Overriding existing kube-secret with a newer resource")
|
|
||||||
// // TODO : implement DeleteKubeConfigSecret(executionID)
|
|
||||||
// deleted, err := k.DeleteKubeConfigSecret(executionId)
|
|
||||||
// _ = deleted
|
|
||||||
// _ = err
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
exists, err := k.GetKubeconfigSecret(context, executionId)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error verifying if kube secret exists in namespace ", executionId)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if exists != nil {
|
||||||
|
fmt.Println("kube-secret already exists in namespace", executionId)
|
||||||
|
fmt.Println("Overriding existing kube-secret with a newer resource")
|
||||||
|
// TODO : implement DeleteKubeConfigSecret(executionID)
|
||||||
|
deleted, err := k.DeleteKubeConfigSecret(executionId)
|
||||||
|
_ = deleted
|
||||||
|
_ = err
|
||||||
|
}
|
||||||
resp, err := k.Set.CoreV1().
|
resp, err := k.Set.CoreV1().
|
||||||
Secrets(executionId).
|
Secrets(executionId).
|
||||||
Apply(context,
|
Create(context, secretManifest, metav1.CreateOptions{})
|
||||||
secretApplyConfig,
|
|
||||||
metav1.ApplyOptions{
|
|
||||||
FieldManager: "admiralty-manager",
|
|
||||||
})
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error while trying to contact API to get secret kube-secret-" + executionId)
|
fmt.Println("Error while trying to contact API to get secret kube-secret-" + executionId)
|
||||||
@@ -414,7 +387,7 @@ func (k *KubernetesService) GetKubeconfigSecret(context context.Context,executio
|
|||||||
Get(context, "kube-secret-"+executionId, metav1.GetOptions{})
|
Get(context, "kube-secret-"+executionId, metav1.GetOptions{})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if(apierrors.IsNotFound(err)){
|
if apierrors.IsNotFound(err) {
|
||||||
fmt.Println("kube-secret not found for execution", executionId)
|
fmt.Println("kube-secret not found for execution", executionId)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
@@ -452,39 +425,7 @@ func getCDRapiKube(client kubernetes.Clientset, ctx context.Context, path string
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dynamicClientApply(executionId string, typeResource string, resourceDefinition schema.GroupVersionResource, ctx context.Context, object map[string]interface{}) ([]byte, error) {
|
func postCDRapiKube(client kubernetes.Clientset, ctx context.Context, path string, body []byte, params ...map[string]string) ([]byte, error) {
|
||||||
cli, err := NewDynamicClient()
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.New("Could not retrieve dynamic client when creating Admiralty Source : " + err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
res, err := cli.Resource(resourceDefinition).
|
|
||||||
Namespace(executionId).
|
|
||||||
Apply(ctx,
|
|
||||||
typeResource + "-" + executionId,
|
|
||||||
&unstructured.Unstructured{Object: object},
|
|
||||||
metav1.ApplyOptions{
|
|
||||||
FieldManager: "kubectl-client-side-apply",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Error from k8s API when applying " + fmt.Sprint(object) + " to " + gvrSources.String() + " : " , err)
|
|
||||||
return nil,err
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// We can add more info to the log with the content of resp if not nil
|
|
||||||
resByte, err := json.Marshal(res)
|
|
||||||
if err != nil {
|
|
||||||
// fmt.Println("Error trying to create a Source on remote cluster : ", err , " : ", res)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return resByte, nil
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func putCDRapiKube(client kubernetes.Clientset, ctx context.Context, path string, body []byte, params ...map[string]string) ([]byte, error){
|
|
||||||
req := client.RESTClient().
|
req := client.RESTClient().
|
||||||
Post().
|
Post().
|
||||||
AbsPath(path).
|
AbsPath(path).
|
||||||
|
|||||||
3
main.go
3
main.go
@@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"oc-datacenter/conf"
|
"oc-datacenter/conf"
|
||||||
_ "oc-datacenter/routers"
|
_ "oc-datacenter/routers"
|
||||||
|
"os"
|
||||||
|
|
||||||
oclib "cloud.o-forge.io/core/oc-lib"
|
oclib "cloud.o-forge.io/core/oc-lib"
|
||||||
"cloud.o-forge.io/core/oc-lib/tools"
|
"cloud.o-forge.io/core/oc-lib/tools"
|
||||||
@@ -20,7 +21,7 @@ func main() {
|
|||||||
// Load the right config file
|
// Load the right config file
|
||||||
o := oclib.GetConfLoader()
|
o := oclib.GetConfLoader()
|
||||||
conf.GetConfig().Mode = o.GetStringDefault("MODE", "kubernetes")
|
conf.GetConfig().Mode = o.GetStringDefault("MODE", "kubernetes")
|
||||||
conf.GetConfig().KubeHost = o.GetStringDefault("KUBERNETES_SERVICE_HOST", "")
|
conf.GetConfig().KubeHost = o.GetStringDefault("KUBERNETES_SERVICE_HOST", os.Getenv("KUBERNETES_SERVICE_HOST"))
|
||||||
conf.GetConfig().KubePort = o.GetStringDefault("KUBERNETES_SERVICE_PORT", "6443")
|
conf.GetConfig().KubePort = o.GetStringDefault("KUBERNETES_SERVICE_PORT", "6443")
|
||||||
|
|
||||||
sDec, err := base64.StdEncoding.DecodeString(o.GetStringDefault("KUBE_CA", ""))
|
sDec, err := base64.StdEncoding.DecodeString(o.GetStringDefault("KUBE_CA", ""))
|
||||||
|
|||||||
BIN
oc-datacenter
BIN
oc-datacenter
Binary file not shown.
BIN
swagger/favicon-16x16.png
Normal file
BIN
swagger/favicon-16x16.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 665 B |
BIN
swagger/favicon-32x32.png
Normal file
BIN
swagger/favicon-32x32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 628 B |
60
swagger/index.html
Normal file
60
swagger/index.html
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<!-- HTML for static distribution bundle build -->
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Swagger UI</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" />
|
||||||
|
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
|
||||||
|
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
|
||||||
|
<style>
|
||||||
|
html
|
||||||
|
{
|
||||||
|
box-sizing: border-box;
|
||||||
|
overflow: -moz-scrollbars-vertical;
|
||||||
|
overflow-y: scroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
*,
|
||||||
|
*:before,
|
||||||
|
*:after
|
||||||
|
{
|
||||||
|
box-sizing: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
body
|
||||||
|
{
|
||||||
|
margin:0;
|
||||||
|
background: #fafafa;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="swagger-ui"></div>
|
||||||
|
|
||||||
|
<script src="./swagger-ui-bundle.js" charset="UTF-8"> </script>
|
||||||
|
<script src="./swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
|
||||||
|
<script>
|
||||||
|
window.onload = function() {
|
||||||
|
// Begin Swagger UI call region
|
||||||
|
const ui = SwaggerUIBundle({
|
||||||
|
url: "swagger.json",
|
||||||
|
dom_id: '#swagger-ui',
|
||||||
|
deepLinking: true,
|
||||||
|
presets: [
|
||||||
|
SwaggerUIBundle.presets.apis,
|
||||||
|
SwaggerUIStandalonePreset
|
||||||
|
],
|
||||||
|
plugins: [
|
||||||
|
SwaggerUIBundle.plugins.DownloadUrl
|
||||||
|
],
|
||||||
|
layout: "StandaloneLayout"
|
||||||
|
});
|
||||||
|
// End Swagger UI call region
|
||||||
|
|
||||||
|
window.ui = ui;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
79
swagger/oauth2-redirect.html
Normal file
79
swagger/oauth2-redirect.html
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en-US">
|
||||||
|
<head>
|
||||||
|
<title>Swagger UI: OAuth2 Redirect</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
'use strict';
|
||||||
|
function run () {
|
||||||
|
var oauth2 = window.opener.swaggerUIRedirectOauth2;
|
||||||
|
var sentState = oauth2.state;
|
||||||
|
var redirectUrl = oauth2.redirectUrl;
|
||||||
|
var isValid, qp, arr;
|
||||||
|
|
||||||
|
if (/code|token|error/.test(window.location.hash)) {
|
||||||
|
qp = window.location.hash.substring(1);
|
||||||
|
} else {
|
||||||
|
qp = location.search.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
arr = qp.split("&");
|
||||||
|
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';});
|
||||||
|
qp = qp ? JSON.parse('{' + arr.join() + '}',
|
||||||
|
function (key, value) {
|
||||||
|
return key === "" ? value : decodeURIComponent(value);
|
||||||
|
}
|
||||||
|
) : {};
|
||||||
|
|
||||||
|
isValid = qp.state === sentState;
|
||||||
|
|
||||||
|
if ((
|
||||||
|
oauth2.auth.schema.get("flow") === "accessCode" ||
|
||||||
|
oauth2.auth.schema.get("flow") === "authorizationCode" ||
|
||||||
|
oauth2.auth.schema.get("flow") === "authorization_code"
|
||||||
|
) && !oauth2.auth.code) {
|
||||||
|
if (!isValid) {
|
||||||
|
oauth2.errCb({
|
||||||
|
authId: oauth2.auth.name,
|
||||||
|
source: "auth",
|
||||||
|
level: "warning",
|
||||||
|
message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (qp.code) {
|
||||||
|
delete oauth2.state;
|
||||||
|
oauth2.auth.code = qp.code;
|
||||||
|
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
|
||||||
|
} else {
|
||||||
|
let oauthErrorMsg;
|
||||||
|
if (qp.error) {
|
||||||
|
oauthErrorMsg = "["+qp.error+"]: " +
|
||||||
|
(qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
|
||||||
|
(qp.error_uri ? "More info: "+qp.error_uri : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
oauth2.errCb({
|
||||||
|
authId: oauth2.auth.name,
|
||||||
|
source: "auth",
|
||||||
|
level: "error",
|
||||||
|
message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
|
||||||
|
}
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.readyState !== 'loading') {
|
||||||
|
run();
|
||||||
|
} else {
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
run();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
3
swagger/swagger-ui-bundle.js
Normal file
3
swagger/swagger-ui-bundle.js
Normal file
File diff suppressed because one or more lines are too long
1
swagger/swagger-ui-bundle.js.map
Normal file
1
swagger/swagger-ui-bundle.js.map
Normal file
File diff suppressed because one or more lines are too long
2
swagger/swagger-ui-es-bundle-core.js
Normal file
2
swagger/swagger-ui-es-bundle-core.js
Normal file
File diff suppressed because one or more lines are too long
3
swagger/swagger-ui-es-bundle.js
Normal file
3
swagger/swagger-ui-es-bundle.js
Normal file
File diff suppressed because one or more lines are too long
3
swagger/swagger-ui-standalone-preset.js
Normal file
3
swagger/swagger-ui-standalone-preset.js
Normal file
File diff suppressed because one or more lines are too long
1
swagger/swagger-ui-standalone-preset.js.map
Normal file
1
swagger/swagger-ui-standalone-preset.js.map
Normal file
File diff suppressed because one or more lines are too long
4
swagger/swagger-ui.css
Normal file
4
swagger/swagger-ui.css
Normal file
File diff suppressed because one or more lines are too long
1
swagger/swagger-ui.css.map
Normal file
1
swagger/swagger-ui.css.map
Normal file
File diff suppressed because one or more lines are too long
2
swagger/swagger-ui.js
Normal file
2
swagger/swagger-ui.js
Normal file
File diff suppressed because one or more lines are too long
1
swagger/swagger-ui.js.map
Normal file
1
swagger/swagger-ui.js.map
Normal file
File diff suppressed because one or more lines are too long
559
swagger/swagger.json
Normal file
559
swagger/swagger.json
Normal file
@@ -0,0 +1,559 @@
|
|||||||
|
{
|
||||||
|
"swagger": "2.0",
|
||||||
|
"info": {
|
||||||
|
"title": "oc-datacenter",
|
||||||
|
"description": "Monitor owned datacenter activity\n",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"termsOfService": "http://cloud.o-forge.io/",
|
||||||
|
"contact": {
|
||||||
|
"email": "admin@o-cloud.io"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "AGPL",
|
||||||
|
"url": "https://www.gnu.org/licenses/agpl-3.0.html"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"basePath": "/oc/",
|
||||||
|
"paths": {
|
||||||
|
"/": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"oc-datacenter/controllersDatacenterController"
|
||||||
|
],
|
||||||
|
"description": "find booking by id\n\u003cbr\u003e",
|
||||||
|
"operationId": "DatacenterController.GetAll",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "is_draft",
|
||||||
|
"description": "draft wished",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "{booking} models.booking"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/admiralty/kubeconfig/{execution}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"admiralty"
|
||||||
|
],
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "execution",
|
||||||
|
"description": "execution id of the workflow",
|
||||||
|
"required": true,
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/admiralty/node/{execution}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"admiralty"
|
||||||
|
],
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "execution",
|
||||||
|
"description": "execution id of the workflow",
|
||||||
|
"required": true,
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/admiralty/secret/{execution}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"admiralty"
|
||||||
|
],
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "execution",
|
||||||
|
"description": "execution id of the workflow",
|
||||||
|
"required": true,
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"post": {
|
||||||
|
"tags": [
|
||||||
|
"admiralty"
|
||||||
|
],
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "execution",
|
||||||
|
"description": "execution id of the workflow",
|
||||||
|
"required": true,
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"in": "body",
|
||||||
|
"name": "kubeconfig",
|
||||||
|
"description": "Kubeconfig to use when creating secret",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/controllers.RemoteKubeconfig"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"201": {
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/admiralty/source/{execution}": {
|
||||||
|
"post": {
|
||||||
|
"tags": [
|
||||||
|
"admiralty"
|
||||||
|
],
|
||||||
|
"description": "Create an Admiralty Source on remote cluster\n\u003cbr\u003e",
|
||||||
|
"operationId": "AdmiraltyController.CreateSource",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "execution",
|
||||||
|
"description": "execution id of the workflow",
|
||||||
|
"required": true,
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"201": {
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/admiralty/target/{execution}": {
|
||||||
|
"post": {
|
||||||
|
"tags": [
|
||||||
|
"admiralty"
|
||||||
|
],
|
||||||
|
"description": "Create an Admiralty Target in the namespace associated to the executionID\n\u003cbr\u003e",
|
||||||
|
"operationId": "AdmiraltyController.CreateAdmiraltyTarget",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "execution",
|
||||||
|
"description": "execution id of the workflow",
|
||||||
|
"required": true,
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"201": {
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/admiralty/targets": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"admiralty"
|
||||||
|
],
|
||||||
|
"description": "find all Admiralty Target\n\u003cbr\u003e",
|
||||||
|
"operationId": "AdmiraltyController.GetAllTargets",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/admiralty/targets/{execution}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"admiralty"
|
||||||
|
],
|
||||||
|
"description": "find one Admiralty Target\n\u003cbr\u003e",
|
||||||
|
"operationId": "AdmiraltyController.GetOneTarget",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "id",
|
||||||
|
"description": "the name of the target to get",
|
||||||
|
"required": true,
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/booking/": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"booking"
|
||||||
|
],
|
||||||
|
"description": "find booking by id\n\u003cbr\u003e",
|
||||||
|
"operationId": "BookingController.GetAll",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "is_draft",
|
||||||
|
"description": "draft wished",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "{booking} models.booking"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"post": {
|
||||||
|
"tags": [
|
||||||
|
"booking"
|
||||||
|
],
|
||||||
|
"description": "create booking\n\u003cbr\u003e",
|
||||||
|
"operationId": "BookingController.Post.",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "body",
|
||||||
|
"name": "booking",
|
||||||
|
"description": "the booking you want to post",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "is_draft",
|
||||||
|
"description": "draft wished",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/models.object"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/booking/check/{id}/{start_date}/{end_date}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"booking"
|
||||||
|
],
|
||||||
|
"description": "check booking\n\u003cbr\u003e",
|
||||||
|
"operationId": "BookingController.Check",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "id",
|
||||||
|
"description": "id of the datacenter",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "start_date",
|
||||||
|
"description": "2006-01-02T15:04:05",
|
||||||
|
"type": "string",
|
||||||
|
"default": "the booking start date"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "end_date",
|
||||||
|
"description": "2006-01-02T15:04:05",
|
||||||
|
"type": "string",
|
||||||
|
"default": "the booking end date"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "is_draft",
|
||||||
|
"description": "draft wished",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/models.object"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/booking/search/execution/{id}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"booking"
|
||||||
|
],
|
||||||
|
"description": "search bookings by execution\n\u003cbr\u003e",
|
||||||
|
"operationId": "BookingController.ExecutionSearch",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "id",
|
||||||
|
"description": "id execution",
|
||||||
|
"required": true,
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "is_draft",
|
||||||
|
"description": "draft wished",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "{workspace} models.workspace"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/booking/search/{start_date}/{end_date}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"booking"
|
||||||
|
],
|
||||||
|
"description": "search bookings\n\u003cbr\u003e",
|
||||||
|
"operationId": "BookingController.Search",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "start_date",
|
||||||
|
"description": "the word search you want to get",
|
||||||
|
"required": true,
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "end_date",
|
||||||
|
"description": "the word search you want to get",
|
||||||
|
"required": true,
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "is_draft",
|
||||||
|
"description": "draft wished",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "{workspace} models.workspace"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/booking/{id}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"booking"
|
||||||
|
],
|
||||||
|
"description": "find booking by id\n\u003cbr\u003e",
|
||||||
|
"operationId": "BookingController.Get",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "id",
|
||||||
|
"description": "the id you want to get",
|
||||||
|
"required": true,
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "{booking} models.booking"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"put": {
|
||||||
|
"tags": [
|
||||||
|
"booking"
|
||||||
|
],
|
||||||
|
"description": "create computes\n\u003cbr\u003e",
|
||||||
|
"operationId": "BookingController.Update",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "id",
|
||||||
|
"description": "the compute id you want to get",
|
||||||
|
"required": true,
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"in": "body",
|
||||||
|
"name": "body",
|
||||||
|
"description": "The compute content",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/models.compute"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "{compute} models.compute"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/session/token/{id}/{duration}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"session"
|
||||||
|
],
|
||||||
|
"description": "find booking by id\n\u003cbr\u003e",
|
||||||
|
"operationId": "SessionController.GetToken",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "id",
|
||||||
|
"description": "id of the datacenter",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "duration",
|
||||||
|
"description": "duration of the token",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "{booking} models.booking"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/version/": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"version"
|
||||||
|
],
|
||||||
|
"description": "get version\n\u003cbr\u003e",
|
||||||
|
"operationId": "VersionController.GetAll",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/version/status": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"version"
|
||||||
|
],
|
||||||
|
"description": "get status\n\u003cbr\u003e",
|
||||||
|
"operationId": "VersionController.Status",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/{id}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"oc-datacenter/controllersDatacenterController"
|
||||||
|
],
|
||||||
|
"description": "find booking by id\n\u003cbr\u003e",
|
||||||
|
"operationId": "DatacenterController.Get",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "id",
|
||||||
|
"description": "the id you want to get",
|
||||||
|
"required": true,
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "is_draft",
|
||||||
|
"description": "draft wished",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "{booking} models.booking"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"definitions": {
|
||||||
|
"controllers.RemoteKubeconfig": {
|
||||||
|
"title": "RemoteKubeconfig",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"Data": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"models.compute": {
|
||||||
|
"title": "compute",
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"models.object": {
|
||||||
|
"title": "object",
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"name": "oc-datacenter/controllersDatacenterController",
|
||||||
|
"description": "Operations about workspace\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "booking",
|
||||||
|
"description": "Operations about workspace\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "session",
|
||||||
|
"description": "Operations about session and token management\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "version",
|
||||||
|
"description": "VersionController operations for Version\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "admiralty",
|
||||||
|
"description": "Operations about the admiralty objects of the datacenter\n"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
399
swagger/swagger.yml
Normal file
399
swagger/swagger.yml
Normal file
@@ -0,0 +1,399 @@
|
|||||||
|
swagger: "2.0"
|
||||||
|
info:
|
||||||
|
title: oc-datacenter
|
||||||
|
description: |
|
||||||
|
Monitor owned datacenter activity
|
||||||
|
version: 1.0.0
|
||||||
|
termsOfService: http://cloud.o-forge.io/
|
||||||
|
contact:
|
||||||
|
email: admin@o-cloud.io
|
||||||
|
license:
|
||||||
|
name: AGPL
|
||||||
|
url: https://www.gnu.org/licenses/agpl-3.0.html
|
||||||
|
basePath: /oc/
|
||||||
|
paths:
|
||||||
|
/:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- oc-datacenter/controllersDatacenterController
|
||||||
|
description: |-
|
||||||
|
find booking by id
|
||||||
|
<br>
|
||||||
|
operationId: DatacenterController.GetAll
|
||||||
|
parameters:
|
||||||
|
- in: query
|
||||||
|
name: is_draft
|
||||||
|
description: draft wished
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: '{booking} models.booking'
|
||||||
|
/{id}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- oc-datacenter/controllersDatacenterController
|
||||||
|
description: |-
|
||||||
|
find booking by id
|
||||||
|
<br>
|
||||||
|
operationId: DatacenterController.Get
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: id
|
||||||
|
description: the id you want to get
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
- in: query
|
||||||
|
name: is_draft
|
||||||
|
description: draft wished
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: '{booking} models.booking'
|
||||||
|
/admiralty/kubeconfig/{execution}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- admiralty
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: execution
|
||||||
|
description: execution id of the workflow
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: ""
|
||||||
|
/admiralty/node/{execution}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- admiralty
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: execution
|
||||||
|
description: execution id of the workflow
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: ""
|
||||||
|
/admiralty/secret/{execution}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- admiralty
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: execution
|
||||||
|
description: execution id of the workflow
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: ""
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- admiralty
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: execution
|
||||||
|
description: execution id of the workflow
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
- in: body
|
||||||
|
name: kubeconfig
|
||||||
|
description: Kubeconfig to use when creating secret
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/controllers.RemoteKubeconfig'
|
||||||
|
responses:
|
||||||
|
"201":
|
||||||
|
description: ""
|
||||||
|
/admiralty/source/{execution}:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- admiralty
|
||||||
|
description: |-
|
||||||
|
Create an Admiralty Source on remote cluster
|
||||||
|
<br>
|
||||||
|
operationId: AdmiraltyController.CreateSource
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: execution
|
||||||
|
description: execution id of the workflow
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"201":
|
||||||
|
description: ""
|
||||||
|
/admiralty/target/{execution}:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- admiralty
|
||||||
|
description: |-
|
||||||
|
Create an Admiralty Target in the namespace associated to the executionID
|
||||||
|
<br>
|
||||||
|
operationId: AdmiraltyController.CreateAdmiraltyTarget
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: execution
|
||||||
|
description: execution id of the workflow
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"201":
|
||||||
|
description: ""
|
||||||
|
/admiralty/targets:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- admiralty
|
||||||
|
description: |-
|
||||||
|
find all Admiralty Target
|
||||||
|
<br>
|
||||||
|
operationId: AdmiraltyController.GetAllTargets
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: ""
|
||||||
|
/admiralty/targets/{execution}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- admiralty
|
||||||
|
description: |-
|
||||||
|
find one Admiralty Target
|
||||||
|
<br>
|
||||||
|
operationId: AdmiraltyController.GetOneTarget
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: id
|
||||||
|
description: the name of the target to get
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: ""
|
||||||
|
/booking/:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- booking
|
||||||
|
description: |-
|
||||||
|
find booking by id
|
||||||
|
<br>
|
||||||
|
operationId: BookingController.GetAll
|
||||||
|
parameters:
|
||||||
|
- in: query
|
||||||
|
name: is_draft
|
||||||
|
description: draft wished
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: '{booking} models.booking'
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- booking
|
||||||
|
description: |-
|
||||||
|
create booking
|
||||||
|
<br>
|
||||||
|
operationId: BookingController.Post.
|
||||||
|
parameters:
|
||||||
|
- in: body
|
||||||
|
name: booking
|
||||||
|
description: the booking you want to post
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
type: string
|
||||||
|
- in: query
|
||||||
|
name: is_draft
|
||||||
|
description: draft wished
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: ""
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/models.object'
|
||||||
|
/booking/{id}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- booking
|
||||||
|
description: |-
|
||||||
|
find booking by id
|
||||||
|
<br>
|
||||||
|
operationId: BookingController.Get
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: id
|
||||||
|
description: the id you want to get
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: '{booking} models.booking'
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- booking
|
||||||
|
description: |-
|
||||||
|
create computes
|
||||||
|
<br>
|
||||||
|
operationId: BookingController.Update
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: id
|
||||||
|
description: the compute id you want to get
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
- in: body
|
||||||
|
name: body
|
||||||
|
description: The compute content
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/models.compute'
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: '{compute} models.compute'
|
||||||
|
/booking/check/{id}/{start_date}/{end_date}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- booking
|
||||||
|
description: |-
|
||||||
|
check booking
|
||||||
|
<br>
|
||||||
|
operationId: BookingController.Check
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: id
|
||||||
|
description: id of the datacenter
|
||||||
|
type: string
|
||||||
|
- in: path
|
||||||
|
name: start_date
|
||||||
|
description: 2006-01-02T15:04:05
|
||||||
|
type: string
|
||||||
|
default: the booking start date
|
||||||
|
- in: path
|
||||||
|
name: end_date
|
||||||
|
description: 2006-01-02T15:04:05
|
||||||
|
type: string
|
||||||
|
default: the booking end date
|
||||||
|
- in: query
|
||||||
|
name: is_draft
|
||||||
|
description: draft wished
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: ""
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/models.object'
|
||||||
|
/booking/search/{start_date}/{end_date}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- booking
|
||||||
|
description: |-
|
||||||
|
search bookings
|
||||||
|
<br>
|
||||||
|
operationId: BookingController.Search
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: start_date
|
||||||
|
description: the word search you want to get
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
- in: path
|
||||||
|
name: end_date
|
||||||
|
description: the word search you want to get
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
- in: query
|
||||||
|
name: is_draft
|
||||||
|
description: draft wished
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: '{workspace} models.workspace'
|
||||||
|
/booking/search/execution/{id}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- booking
|
||||||
|
description: |-
|
||||||
|
search bookings by execution
|
||||||
|
<br>
|
||||||
|
operationId: BookingController.ExecutionSearch
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: id
|
||||||
|
description: id execution
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
- in: query
|
||||||
|
name: is_draft
|
||||||
|
description: draft wished
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: '{workspace} models.workspace'
|
||||||
|
/session/token/{id}/{duration}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- session
|
||||||
|
description: |-
|
||||||
|
find booking by id
|
||||||
|
<br>
|
||||||
|
operationId: SessionController.GetToken
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: id
|
||||||
|
description: id of the datacenter
|
||||||
|
type: string
|
||||||
|
- in: path
|
||||||
|
name: duration
|
||||||
|
description: duration of the token
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: '{booking} models.booking'
|
||||||
|
/version/:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- version
|
||||||
|
description: |-
|
||||||
|
get version
|
||||||
|
<br>
|
||||||
|
operationId: VersionController.GetAll
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: ""
|
||||||
|
/version/status:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- version
|
||||||
|
description: |-
|
||||||
|
get status
|
||||||
|
<br>
|
||||||
|
operationId: VersionController.Status
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: ""
|
||||||
|
definitions:
|
||||||
|
controllers.RemoteKubeconfig:
|
||||||
|
title: RemoteKubeconfig
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
Data:
|
||||||
|
type: string
|
||||||
|
models.compute:
|
||||||
|
title: compute
|
||||||
|
type: object
|
||||||
|
models.object:
|
||||||
|
title: object
|
||||||
|
type: object
|
||||||
|
tags:
|
||||||
|
- name: oc-datacenter/controllersDatacenterController
|
||||||
|
description: |
|
||||||
|
Operations about workspace
|
||||||
|
- name: booking
|
||||||
|
description: |
|
||||||
|
Operations about workspace
|
||||||
|
- name: session
|
||||||
|
description: |
|
||||||
|
Operations about session and token management
|
||||||
|
- name: version
|
||||||
|
description: |
|
||||||
|
VersionController operations for Version
|
||||||
|
- name: admiralty
|
||||||
|
description: |
|
||||||
|
Operations about the admiralty objects of the datacenter
|
||||||
Reference in New Issue
Block a user