Merge branch 'main' into v1.next_canary

This commit is contained in:
Michael Quigley
2025-04-23 11:28:03 -04:00
37 changed files with 4138 additions and 1304 deletions

View File

@@ -0,0 +1,50 @@
package sdk
import (
httptransport "github.com/go-openapi/runtime/client"
"github.com/openziti/zrok/environment/env_core"
restEnvironment "github.com/openziti/zrok/rest_client_zrok/environment"
"github.com/pkg/errors"
)
func EnableEnvironment(root env_core.Root, request *EnableRequest) (*Environment, error) {
zrok, err := root.Client()
if err != nil {
return nil, errors.Wrap(err, "could not create zrok client")
}
auth := httptransport.APIKeyAuth("X-TOKEN", "header", root.Environment().AccountToken)
req := restEnvironment.NewEnableParams()
req.Body.Description = request.Description
req.Body.Host = request.Host
resp, err := zrok.Environment.Enable(req, auth)
if err != nil {
return nil, err
}
return &Environment{
Host: request.Host,
Description: request.Description,
ZitiIdentity: resp.Payload.Identity,
ZitiConfig: resp.Payload.Cfg,
}, nil
}
func DisableEnvironment(env *Environment, root env_core.Root) error {
zrok, err := root.Client()
if err != nil {
return errors.Wrap(err, "could not create zrok client")
}
auth := httptransport.APIKeyAuth("X-TOKEN", "header", root.Environment().AccountToken)
req := restEnvironment.NewDisableParams()
req.Body.Identity = env.ZitiIdentity
_, err = zrok.Environment.Disable(req, auth)
if err != nil {
return err
}
return nil
}

View File

@@ -2,6 +2,18 @@ package sdk
import "time"
type EnableRequest struct {
Host string
Description string
}
type Environment struct {
Host string
Description string
ZitiIdentity string
ZitiConfig string
}
type BackendMode string
const (