github.com/kubeshop/testkube@v1.17.23/pkg/cloud/client/environments.go (about)

     1  package client
     2  
     3  import (
     4  	"github.com/kubeshop/testkube/pkg/http"
     5  )
     6  
     7  func NewEnvironmentsClient(baseUrl, token, orgID string) *EnvironmentsClient {
     8  	return &EnvironmentsClient{
     9  		RESTClient: RESTClient[Environment]{
    10  			BaseUrl: baseUrl,
    11  			Path:    "/organizations/" + orgID + "/environments",
    12  			Client:  http.NewClient(),
    13  			Token:   token,
    14  		},
    15  	}
    16  }
    17  
    18  type Environment struct {
    19  	Name              string `json:"name"`
    20  	Id                string `json:"id"`
    21  	Connected         bool   `json:"connected"`
    22  	Owner             string `json:"owner"`
    23  	InstallCommand    string `json:"installCommand,omitempty"`
    24  	InstallCommandCli string `json:"installCommandCli,omitempty"`
    25  	OrganizationId    string `json:"organizationId,omitempty"`
    26  	AgentToken        string `json:"agentToken,omitempty"`
    27  }
    28  
    29  type EnvironmentsClient struct {
    30  	RESTClient[Environment]
    31  }
    32  
    33  func (c EnvironmentsClient) Create(env Environment) (Environment, error) {
    34  	return c.RESTClient.Create(env, "/organizations/"+env.Owner+"/environments")
    35  }