domain

package
v0.2.0-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApiVersion = "v1"

	KindConfig      = "Config"
	KindWorkspace   = "Workspace"
	KindProtoFile   = "ProtoFile"
	KindEnv         = "Environment"
	KindRequest     = "Request"
	KindPreferences = "Preferences"
	KindCollection  = "Collection"
)
View Source
const (
	RequestTypeHTTP = "http"
	RequestTypeGRPC = "grpc"

	RequestMethodGET     = "GET"
	RequestMethodPOST    = "POST"
	RequestMethodPUT     = "PUT"
	RequestMethodDELETE  = "DELETE"
	RequestMethodPATCH   = "PATCH"
	RequestMethodHEAD    = "HEAD"
	RequestMethodOPTIONS = "OPTIONS"
	RequestMethodCONNECT = "CONNECT"
	RequestMethodTRACE   = "TRACE"

	RequestBodyTypeNone       = "none"
	RequestBodyTypeJSON       = "json"
	RequestBodyTypeXML        = "xml"
	RequestBodyTypeText       = "text"
	RequestBodyTypeForm       = "form"
	RequestBodyTypeBinary     = "binary"
	RequestBodyTypeUrlEncoded = "urlEncoded"

	PrePostTypeNone      = "none"
	PrePostTypePython    = "python"
	PrePostTypeShell     = "ssh"
	PrePostTypeSSHTunnel = "sshTunnel"
	PrePostTypeK8sTunnel = "k8sTunnel"
)
View Source
const (
	AuthTypeNone   = "none"
	AuthTypeBasic  = "basic"
	AuthTypeToken  = "token"
	AuthTypeAPIKey = "apiKey"
)
View Source
const (
	PostRequestTypeNone         = "none"
	PostRequestTypeSetEnv       = "setEnv"
	PostRequestTypePythonScript = "pythonScript"
	PostRequestTypeK8sTunnel    = "k8sTunnel"
	PostRequestTypeSSHTunnel    = "sshTunnel"
	PostRequestTypeShellScript  = "shellScript"
)
View Source
const (
	PostRequestSetFromResponseHeader = "responseHeader"
	PostRequestSetFromResponseBody   = "responseBody"
	PostRequestSetFromResponseCookie = "responseCookie"
)
View Source
const (
	BodyTypeNone       = "none"
	BodyTypeJSON       = "json"
	BodyTypeText       = "text"
	BodyTypeXML        = "xml"
	BodyTypeFormData   = "formData"
	BodyTypeBinary     = "binary"
	BodyTypeUrlencoded = "urlencoded"
)
View Source
const (
	FormFieldTypeText = "text"
	FormFieldTypeFile = "file"
)
View Source
const DefaultWorkspaceName = "Default Workspace"

Variables

This section is empty.

Functions

func Clone

func Clone[T any](org *T) (*T, error)

func CompareAPIKey

func CompareAPIKey(a, b *APIKeyAuth) bool

func CompareAuth

func CompareAuth(a, b Auth) bool

func CompareBasicAuth

func CompareBasicAuth(a, b *BasicAuth) bool

func CompareBody

func CompareBody(a, b Body) bool

func CompareEnvValue

func CompareEnvValue(a, b KeyValue) bool

func CompareFormData

func CompareFormData(a, b FormData) bool

func CompareFormField

func CompareFormField(a, b FormField) bool

func CompareGRPCMethods

func CompareGRPCMethods(a, b []GRPCMethod) bool

func CompareGRPCRequestSpecs

func CompareGRPCRequestSpecs(a, b *GRPCRequestSpec) bool

func CompareGRPCServices

func CompareGRPCServices(a, b []GRPCService) bool

func CompareHTTPRequestSpecs

func CompareHTTPRequestSpecs(a, b *HTTPRequestSpec) bool

func CompareHTTPRequests

func CompareHTTPRequests(a, b *HTTPRequest) bool

func CompareHTTPResponses

func CompareHTTPResponses(a, b HTTPResponse) bool

func CompareKeyValues

func CompareKeyValues(a, b []KeyValue) bool

CompareKeyValues compares two slices of KeyValue and returns true if they are equal

func CompareKubernetesTunnel

func CompareKubernetesTunnel(a, b *KubernetesTunnel) bool

func ComparePostRequest

func ComparePostRequest(a, b PostRequest) bool

func ComparePostRequestSet

func ComparePostRequestSet(a, b PostRequestSet) bool

func ComparePreRequest

func ComparePreRequest(a, b PreRequest) bool

func CompareProtoFileSpecs

func CompareProtoFileSpecs(a, b ProtoFileSpec) bool

func CompareProtoFiles

func CompareProtoFiles(a, b *ProtoFile) bool

func CompareRequests

func CompareRequests(a, b *Request) bool

func CompareSShTunnel

func CompareSShTunnel(a, b *SShTunnel) bool

func CompareServerInfo

func CompareServerInfo(a, b ServerInfo) bool

func CompareSettings

func CompareSettings(a, b Settings) bool

func CompareTokenAuth

func CompareTokenAuth(a, b *TokenAuth) bool

func EncodeQueryParams

func EncodeQueryParams(params []KeyValue) string

func IsHTTPResponseEmpty

func IsHTTPResponseEmpty(r HTTPResponse) bool

func KeyValuesToText

func KeyValuesToText(values []KeyValue) string

Types

type APIKeyAuth

type APIKeyAuth struct {
	Key   string `yaml:"key"`
	Value string `yaml:"value"`
}

func (*APIKeyAuth) Clone

func (a *APIKeyAuth) Clone() *APIKeyAuth

type ActiveWorkspace

type ActiveWorkspace struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type Auth

type Auth struct {
	Type       string      `yaml:"type"`
	BasicAuth  *BasicAuth  `yaml:"basicAuth,omitempty"`
	TokenAuth  *TokenAuth  `yaml:"tokenAuth,omitempty"`
	APIKeyAuth *APIKeyAuth `yaml:"apiKey,omitempty"`
}

func (*Auth) Clone

func (a *Auth) Clone() Auth

type BasicAuth

type BasicAuth struct {
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

func (*BasicAuth) Clone

func (a *BasicAuth) Clone() *BasicAuth

type Body

type Body struct {
	Type string `yaml:"type"`
	// Can be json, xml, or plain text
	Data string `yaml:"data"`

	FormData       FormData   `yaml:"formData,omitempty"`
	URLEncoded     []KeyValue `yaml:"urlEncoded,omitempty"`
	BinaryFilePath string     `yaml:"binaryFilePath,omitempty"`
}

func (*Body) Clone

func (b *Body) Clone() *Body

type ColSpec

type ColSpec struct {
	Requests []*Request `yaml:"requests"`
}

type Collection

type Collection struct {
	ApiVersion string   `yaml:"apiVersion"`
	Kind       string   `yaml:"kind"`
	MetaData   MetaData `yaml:"metadata"`
	Spec       ColSpec  `yaml:"spec"`

	FilePath string `yaml:"-"`
}

func NewCollection

func NewCollection(name string) *Collection

func (*Collection) AddRequest

func (c *Collection) AddRequest(req *Request)

func (*Collection) Clone

func (c *Collection) Clone() *Collection

func (*Collection) FindRequestByID

func (c *Collection) FindRequestByID(id string) *Request

func (*Collection) RemoveRequest

func (c *Collection) RemoveRequest(req *Request)

type Config

type Config struct {
	ApiVersion string     `yaml:"apiVersion"`
	Kind       string     `yaml:"kind"`
	MetaData   MetaData   `yaml:"metadata"`
	Spec       ConfigSpec `yaml:"spec"`
}

func NewConfig

func NewConfig() *Config

type ConfigSpec

type ConfigSpec struct {
	ActiveWorkspace *ActiveWorkspace `yaml:"activeWorkspace"`
}

type EnvSpec

type EnvSpec struct {
	Values []KeyValue `yaml:"values"`
}

func (*EnvSpec) Clone

func (e *EnvSpec) Clone() EnvSpec

type Environment

type Environment struct {
	ApiVersion string   `yaml:"apiVersion"`
	Kind       string   `yaml:"kind"`
	MetaData   MetaData `yaml:"metadata"`
	Spec       EnvSpec  `yaml:"spec"`
	FilePath   string   `yaml:"-"`
}

func NewEnvironment

func NewEnvironment(name string) *Environment

func (*Environment) ApplyToGRPCRequest

func (e *Environment) ApplyToGRPCRequest(req *GRPCRequestSpec)

func (*Environment) Clone

func (e *Environment) Clone() *Environment

func (*Environment) SetKey

func (e *Environment) SetKey(key string, value string)

type FormData

type FormData struct {
	Fields []FormField `yaml:"fields"`
}

type FormField

type FormField struct {
	ID     string   `yaml:"id"`
	Type   string   `yaml:"type"`
	Key    string   `yaml:"key"`
	Value  string   `yaml:"value"`
	Files  []string `yaml:"files"`
	Enable bool     `yaml:"enable"`
}

type GRPCMethod

type GRPCMethod struct {
	FullName          string `yaml:"fullName"`
	Name              string `yaml:"name"`
	IsStreamingClient bool   `yaml:"IsStreamingClient"`
	IsStreamingServer bool   `yaml:"IsStreamingServer"`
}

type GRPCRequestSpec

type GRPCRequestSpec struct {
	LasSelectedMethod string        `yaml:"lastSelectedMethod"`
	Metadata          []KeyValue    `yaml:"metadata"`
	Auth              Auth          `yaml:"auth"`
	ServerInfo        ServerInfo    `yaml:"serverInfo"`
	Settings          Settings      `yaml:"settings"`
	Body              string        `yaml:"body"`
	Services          []GRPCService `yaml:"services"`
}

func (*GRPCRequestSpec) Clone

func (g *GRPCRequestSpec) Clone() *GRPCRequestSpec

func (*GRPCRequestSpec) HasMethod

func (g *GRPCRequestSpec) HasMethod(method string) bool

type GRPCResponseDetail

type GRPCResponseDetail struct {
	Response   string
	Metadata   []KeyValue
	Trailers   []KeyValue
	StatusCode int
	Duration   time.Duration
	Size       int
	Error      error

	StatueCode int
	Status     string
}

type GRPCService

type GRPCService struct {
	Name    string `yaml:"name"`
	Methods []GRPCMethod
}

type HTTPRequest

type HTTPRequest struct {
	Headers []KeyValue `yaml:"headers"`

	PathParams  []KeyValue `yaml:"pathParams"`
	QueryParams []KeyValue `yaml:"queryParams"`

	Body Body `yaml:"body"`

	Auth Auth `yaml:"auth"`

	PreRequest  PreRequest  `yaml:"preRequest"`
	PostRequest PostRequest `yaml:"postRequest"`
}

func (*HTTPRequest) Clone

func (r *HTTPRequest) Clone() *HTTPRequest

type HTTPRequestSpec

type HTTPRequestSpec struct {
	Method string `yaml:"method"`
	URL    string `yaml:"url"`

	LastUsedEnvironment LastUsedEnvironment `yaml:"lastUsedEnvironment"`

	Request   *HTTPRequest   `yaml:"request"`
	Responses []HTTPResponse `yaml:"responses"`
}

func (*HTTPRequestSpec) Clone

func (h *HTTPRequestSpec) Clone() *HTTPRequestSpec

type HTTPResponse

type HTTPResponse struct {
	Headers []KeyValue `yaml:"headers"`
	Body    string     `yaml:"body"`
	Cookies []KeyValue `yaml:"cookies"`
}

type HTTPResponseDetail

type HTTPResponseDetail struct {
	Response   string
	Headers    []KeyValue
	Cookies    []KeyValue
	StatusCode int
	Duration   time.Duration
	Size       int

	Error error
}

type KeyValue

type KeyValue struct {
	ID     string `yaml:"id"`
	Key    string `yaml:"key"`
	Value  string `yaml:"value"`
	Enable bool   `yaml:"enable"`
}

func MetadataToKeyValue

func MetadataToKeyValue(md metadata.MD) []KeyValue

func ParsePathParams

func ParsePathParams(params string) []KeyValue

func ParseQueryParams

func ParseQueryParams(params string) []KeyValue

type KubernetesTunnel

type KubernetesTunnel struct {
	Target     string `yaml:"target"`
	TargetType string `yaml:"targetType"`

	// The port to be used in the local machine
	LocalPort  int `yaml:"localPort"`
	TargetPort int `yaml:"targetPort"`
}

type LastUsedEnvironment

type LastUsedEnvironment struct {
	ID   string `yaml:"id"`
	Name string `yaml:"name"`
}

type Log

type Log struct {
	Time    time.Time
	Level   string
	Message string
}

type MetaData

type MetaData struct {
	ID   string `yaml:"id"`
	Name string `yaml:"name"`
}

type PostRequest

type PostRequest struct {
	Type           string         `yaml:"type"`
	Script         string         `yaml:"script"`
	PostRequestSet PostRequestSet `yaml:"set"`
}

type PostRequestSet

type PostRequestSet struct {
	Target     string `yaml:"target"`
	StatusCode int    `yaml:"statusCode"`
	// From can be response header, response body or cookies
	From    string `yaml:"from"`
	FromKey string `yaml:"fromKey"`
}

type PreRequest

type PreRequest struct {
	Type   string `yaml:"type"`
	Script string `yaml:"script"`

	SShTunnel        *SShTunnel        `yaml:"sshTunnel,omitempty"`
	KubernetesTunnel *KubernetesTunnel `yaml:"kubernetesTunnel,omitempty"`
}

type PrefSpec

type PrefSpec struct {
	DarkMode            bool                `yaml:"darkMode"`
	SelectedEnvironment SelectedEnvironment `yaml:"selectedEnvironment"`
}

type Preferences

type Preferences struct {
	ApiVersion string   `yaml:"apiVersion"`
	Kind       string   `yaml:"kind"`
	MetaData   MetaData `yaml:"metadata"`
	Spec       PrefSpec `yaml:"spec"`
}

func NewPreferences

func NewPreferences() *Preferences

type ProtoFile

type ProtoFile struct {
	ApiVersion string   `yaml:"apiVersion"`
	Kind       string   `yaml:"kind"`
	MetaData   MetaData `yaml:"metadata"`
	FilePath   string   `yaml:"-"`

	Spec ProtoFileSpec `yaml:"spec"`
}

func NewProtoFile

func NewProtoFile(name string) *ProtoFile

type ProtoFileSpec

type ProtoFileSpec struct {
	Path     string   `yaml:"path"`
	Package  string   `yaml:"package"`
	Services []string `yaml:"services"`
}

type Request

type Request struct {
	ApiVersion string      `yaml:"apiVersion"`
	Kind       string      `yaml:"kind"`
	MetaData   RequestMeta `yaml:"metadata"`
	Spec       RequestSpec `yaml:"spec"`
	FilePath   string      `yaml:"-"`

	CollectionName string `yaml:"-"`
	CollectionID   string `yaml:"-"`
}

func NewGRPCRequest

func NewGRPCRequest(name string) *Request

func NewHTTPRequest

func NewHTTPRequest(name string) *Request

func (*Request) Clone

func (r *Request) Clone() *Request

func (*Request) SetDefaultValues

func (r *Request) SetDefaultValues()

func (*Request) SetDefaultValuesForGRPC

func (r *Request) SetDefaultValuesForGRPC()

func (*Request) SetDefaultValuesForHTTP

func (r *Request) SetDefaultValuesForHTTP()

type RequestMeta

type RequestMeta struct {
	ID   string `yaml:"id"`
	Name string `yaml:"name"`
	Type string `yaml:"type"`
}

type RequestSpec

type RequestSpec struct {
	GRPC *GRPCRequestSpec `yaml:"grpc,omitempty"`
	HTTP *HTTPRequestSpec `yaml:"http,omitempty"`
}

func (*RequestSpec) Clone

func (r *RequestSpec) Clone() *RequestSpec

type SShTunnel

type SShTunnel struct {
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	User     string `yaml:"user"`
	Password string `yaml:"password"`
	KeyPath  string `yaml:"keyPath"`

	// The port to be used in the local machine
	LocalPort  int `yaml:"localPort"`
	TargetPort int `yaml:"targetPort"`

	Flags []string `yaml:"flags"`
}

type SelectedEnvironment

type SelectedEnvironment struct {
	ID   string `yaml:"id"`
	Name string `yaml:"name"`
}

type ServerInfo

type ServerInfo struct {
	Address string `yaml:"address"`

	ServerReflection bool     `yaml:"serverReflection"`
	ProtoFiles       []string `yaml:"protoFiles"`
}

type Settings

type Settings struct {
	Insecure            bool   `yaml:"insecure"`
	TimeoutMilliseconds int    `yaml:"timeoutMilliseconds"`
	NameOverride        string `yaml:"nameOverride"`

	RootCertFile   string `yaml:"rootCertFile"`
	ClientCertFile string `yaml:"clientCertFile"`
	ClientKeyFile  string `yaml:"clientKeyFile"`
}

type TokenAuth

type TokenAuth struct {
	Token string `yaml:"token"`
}

func (*TokenAuth) Clone

func (a *TokenAuth) Clone() *TokenAuth

type Workspace

type Workspace struct {
	ApiVersion string   `yaml:"apiVersion"`
	Kind       string   `yaml:"kind"`
	MetaData   MetaData `yaml:"metadata"`
	FilePath   string   `yaml:"-"`
}

func NewDefaultWorkspace

func NewDefaultWorkspace() *Workspace

func NewWorkspace

func NewWorkspace(name string) *Workspace

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL