Documentation
¶
Overview ¶
Package tbclient provides client functions to interact with CB-Tumblebug API
Package tbclient provides client functions to interact with CB-Tumblebug API ¶
Package tbclient provides client functions to interact with CB-Tumblebug API ¶
Package tbclient provides client functions to interact with CB-Tumblebug API ¶
Package tbclient provides client functions to interact with CB-Tumblebug API ¶
Package tbclient provides client functions to interact with CB-Tumblebug API ¶
Package tbclient provides client functions to interact with CB-Tumblebug API ¶
Package tbclient provides client functions to interact with CB-Tumblebug API ¶
Package tbclient provides client functions to interact with CB-Tumblebug API ¶
Package tbclient provides client functions to interact with CB-Tumblebug API ¶
Package tbclient provides client functions to interact with CB-Tumblebug API ¶
Package tbclient provides client functions to interact with CB-Tumblebug API ¶
Package tbclient provides client functions to interact with CB-Tumblebug API
Index ¶
- Constants
- func GetCacheDuration(ctx context.Context) (time.Duration, bool)
- func Init(cfg ApiConfig)
- func SetCacheDuration(ctx context.Context, d time.Duration) context.Context
- type ApiConfig
- type CacheItem
- type CircuitBreakerState
- type NLBListResponse
- type Session
- func (s *Session) CreateInfra(nsId string, reqBody tbmodel.InfraReq) (tbmodel.InfraInfo, error)
- func (s *Session) CreateInfraDynamic(nsId string, reqBody tbmodel.InfraDynamicReq) (tbmodel.InfraInfo, error)
- func (s *Session) CreateNamespace(nsReq tbmodel.NsReq) (tbmodel.NsInfo, error)
- func (s *Session) CreateNlb(nsId, infraId string, req tbmodel.NLBReq) (tbmodel.NLBInfo, error)
- func (s *Session) CreateObjectStorage(nsId string, req tbmodel.ObjectStorageCreateRequest) (tbmodel.ObjectStorageInfo, error)
- func (s *Session) CreateSecurityGroup(nsId string, reqBody tbmodel.SecurityGroupReq, option string) (tbmodel.SecurityGroupInfo, error)
- func (s *Session) CreateSshKey(nsId string, reqBody tbmodel.SshKeyReq) (tbmodel.SshKeyInfo, error)
- func (s *Session) CreateVNet(nsId string, reqBody tbmodel.VNetReq) (tbmodel.VNetInfo, error)
- func (s *Session) Delete(url string) (*resty.Response, error)
- func (s *Session) DeleteInfra(nsId, infraId, option string) (tbmodel.IdList, error)
- func (s *Session) DeleteNlb(nsId, infraId, nlbId string) error
- func (s *Session) DeleteObjectStorage(nsId string, osId string, option string) error
- func (s *Session) DeleteObjectStorageCORS(nsId string, osId string) error
- func (s *Session) DeleteSecurityGroup(nsId, securityGroupId string) (tbmodel.SimpleMsg, error)
- func (s *Session) DeleteSharedResources(nsId string) (tbmodel.IdList, error)
- func (s *Session) DeleteSshKey(nsId, sshKeyId string) (tbmodel.SimpleMsg, error)
- func (s *Session) DeleteStorageObject(nsId, osId, objectKey string) error
- func (s *Session) DeleteVNet(nsId, vNetId, action string) (tbmodel.SimpleMsg, error)
- func (s *Session) Execute(method, url string) (*resty.Response, error)
- func (s *Session) ExistObjectStorage(nsId string, osId string) (bool, error)
- func (s *Session) Get(url string) (*resty.Response, error)
- func (s *Session) GetConnConfig(connectionConfigName string) (tbmodel.ConnConfig, error)
- func (s *Session) GetNlb(nsId, infraId, nlbId string) (tbmodel.NLBInfo, error)
- func (s *Session) GetObjectStorage(nsId string, osId string) (tbmodel.ObjectStorageInfo, error)
- func (s *Session) GetObjectStorageCORS(nsId string, osId string) (tbmodel.ObjectStorageGetCorsResponse, error)
- func (s *Session) GetObjectStorageLocation(nsId string, osId string) (tbmodel.ObjectStorageLocationResponse, error)
- func (s *Session) GetObjectStorageSupport(cspType string) (tbmodel.ObjectStorageSupportResponse, error)
- func (s *Session) GetObjectStorageVersioning(nsId string, osId string) (tbmodel.ObjectStorageGetVersioningResponse, error)
- func (s *Session) GetStorageObject(nsId, osId, objectKey string) (tbmodel.Object, error)
- func (s *Session) Head(url string) (*resty.Response, error)
- func (s *Session) InfraRecommendSpec(planToSearchProperVm string) ([]tbmodel.SpecInfo, error)
- func (s *Session) IsReady() (bool, *string, error)
- func (s *Session) ListNlbs(nsId, infraId string) (NLBListResponse, error)
- func (s *Session) ListObjectStorageObjects(nsId string, osId string) (tbmodel.ObjectStorageListObjectsResponse, error)
- func (s *Session) ListObjectStorages(nsId string, option string, filterKey string, filterVal string) (tbmodel.ObjectStorageListResponse, error)
- func (s *Session) NoCache() *Session
- func (s *Session) Post(url string) (*resty.Response, error)
- func (s *Session) Put(url string) (*resty.Response, error)
- func (s *Session) ReadAllInfra(nsId string) (TbInfraInfoList, error)
- func (s *Session) ReadInfra(nsId, infraId string) (tbmodel.InfraInfo, error)
- func (s *Session) ReadInfraAccessInfo(nsId, infraId, option, accessInfoOption string) (tbmodel.InfraAccessInfo, error)
- func (s *Session) ReadInfraIDs(nsId string) (tbmodel.IdList, error)
- func (s *Session) ReadNamespace(nsId string) (tbmodel.NsInfo, error)
- func (s *Session) ReadRegionInfo(providerName string, regionName string) (tbmodel.RegionDetail, error)
- func (s *Session) ReadSecurityGroup(nsId, securityGroupId string) (tbmodel.SecurityGroupInfo, error)
- func (s *Session) ReadSshKey(nsId, sshKeyId string) (tbmodel.SshKeyInfo, error)
- func (s *Session) ReadVNet(nsId, vNetId string) (tbmodel.VNetInfo, error)
- func (s *Session) ReadVmOsImage(nsId, vmOsImageId string) (tbmodel.ImageInfo, error)
- func (s *Session) ReadVmSpec(nsId, vmSpecId string) (tbmodel.SpecInfo, error)
- func (s *Session) ReviewSpecImagePair(req tbmodel.SpecImagePairReviewReq) (tbmodel.SpecImagePairReviewResult, error)
- func (s *Session) SearchVmOsImage(nsId string, searchImageReq tbmodel.SearchImageRequest) (tbmodel.SearchImageResponse, error)
- func (s *Session) SetBody(body any) *Session
- func (s *Session) SetCacheDuration(d time.Duration) *Session
- func (s *Session) SetContext(ctx context.Context) *Session
- func (s *Session) SetHeader(key, value string) *Session
- func (s *Session) SetHeaders(headers map[string]string) *Session
- func (s *Session) SetObjectStorageCORS(nsId string, osId string, req tbmodel.ObjectStorageSetCorsRequest) error
- func (s *Session) SetObjectStorageVersioning(nsId string, osId string, req tbmodel.ObjectStorageSetVersioningRequest) error
- func (s *Session) SetQueryParam(key, value string) *Session
- func (s *Session) SetQueryParams(params map[string]string) *Session
- func (s *Session) SetResult(res any) *Session
- func (s *Session) SetTraceInfo(ctx context.Context) *Session
- type TbInfraInfoList
- type TumblebugClient
- type TumblebugTransport
Constants ¶
const ( // VeryShortDuration is a duration for very short-term cache VeryShortDuration = 1 * time.Second // ShortDuration is a duration for short-term cache ShortDuration = 2 * time.Second // MediumDuration is a duration for medium-term cache MediumDuration = 5 * time.Second // LongDuration is a duration for long-term cache LongDuration = 10 * time.Second )
const (
// MaxDebugBodyLength is the maximum length of response body for debug logs
MaxDebugBodyLength = 50000
)
Variables ¶
This section is empty.
Functions ¶
func GetCacheDuration ¶ added in v0.5.1
GetCacheDuration retrieves cache duration from the context
Types ¶
type ApiConfig ¶
type ApiConfig struct {
RestUrl string
Username string
Password string
Timeout time.Duration
CacheDuration time.Duration
HttpTransport http.RoundTripper
}
ApiConfig holds the configuration for the Tumblebug client.
type CacheItem ¶ added in v0.5.1
type CacheItem struct {
ResponseBytes []byte
StatusCode int
Header http.Header
ExpiresAt time.Time
}
CacheItem is a struct to store cached item
type CircuitBreakerState ¶ added in v0.5.1
CircuitBreakerState represents the state of a circuit breaker for a specific request
type NLBListResponse ¶ added in v0.5.3
NLBListResponse is the response body for GET /ns/{nsId}/infra/{infraId}/nlb.
type Session ¶ added in v0.5.1
type Session struct {
// contains filtered or unexported fields
}
Session represents a single request scope. It holds the request-specific configuration (headers, context, etc.).
func NewSession ¶ added in v0.5.1
func NewSession() *Session
NewSession creates a new Session using the global client.
func (*Session) CreateInfra ¶ added in v0.5.1
CreateInfra creates a new Infra (Infrastructure) in the specified namespace
func (*Session) CreateInfraDynamic ¶ added in v0.5.1
func (s *Session) CreateInfraDynamic(nsId string, reqBody tbmodel.InfraDynamicReq) (tbmodel.InfraInfo, error)
CreateInfraDynamic creates a new Infra (Infrastructure) with defaults in the specified namespace
func (*Session) CreateNamespace ¶ added in v0.5.1
CreateNamespace creates a new namespace in Tumblebug
func (*Session) CreateNlb ¶ added in v0.5.3
CreateNlb creates a new NLB in the specified namespace and infra.
func (*Session) CreateObjectStorage ¶ added in v0.5.1
func (s *Session) CreateObjectStorage(nsId string, req tbmodel.ObjectStorageCreateRequest) (tbmodel.ObjectStorageInfo, error)
CreateObjectStorage creates a new object storage (bucket)
func (*Session) CreateSecurityGroup ¶ added in v0.5.1
func (s *Session) CreateSecurityGroup(nsId string, reqBody tbmodel.SecurityGroupReq, option string) (tbmodel.SecurityGroupInfo, error)
CreateSecurityGroup creates a new Security Group in the specified namespace
func (*Session) CreateSshKey ¶ added in v0.5.1
CreateSshKey creates a new SSH Key in the specified namespace
func (*Session) CreateVNet ¶ added in v0.5.1
CreateVNet creates a new Virtual Network (VNet) in the specified namespace
func (*Session) DeleteInfra ¶ added in v0.5.1
DeleteInfra deletes a specific Infra (Infrastructure) in the specified namespace
func (*Session) DeleteObjectStorage ¶ added in v0.5.1
DeleteObjectStorage deletes an object storage (bucket). option controls the deletion behavior (mutually exclusive):
- "" : Standard delete — fails if the bucket is not empty.
- "empty" : Empty the bucket first, then delete.
- "force" : Force-delete with all contents (passed to Spider as force=true).
- "reconcile": Remove only Tumblebug metadata without calling the CSP delete API.
func (*Session) DeleteObjectStorageCORS ¶ added in v0.5.1
DeleteObjectStorageCORS deletes the CORS configuration of an object storage (bucket)
func (*Session) DeleteSecurityGroup ¶ added in v0.5.1
DeleteSecurityGroup deletes a specific Security Group in the specified namespace
func (*Session) DeleteSharedResources ¶ added in v0.5.1
func (*Session) DeleteSshKey ¶ added in v0.5.1
func (*Session) DeleteStorageObject ¶ added in v0.5.1
DeleteStorageObject deletes a specific object from an object storage bucket.
func (*Session) DeleteVNet ¶ added in v0.5.1
func (*Session) Execute ¶ added in v0.5.1
Execute executes the request with the given method and URL.
func (*Session) ExistObjectStorage ¶ added in v0.5.1
ExistObjectStorage checks the existence of an object storage (bucket)
func (*Session) GetConnConfig ¶ added in v0.5.1
func (s *Session) GetConnConfig(connectionConfigName string) (tbmodel.ConnConfig, error)
func (*Session) GetObjectStorage ¶ added in v0.5.1
GetObjectStorage retrieves details of an object storage (bucket)
func (*Session) GetObjectStorageCORS ¶ added in v0.5.1
func (s *Session) GetObjectStorageCORS(nsId string, osId string) (tbmodel.ObjectStorageGetCorsResponse, error)
GetObjectStorageCORS retrieves the CORS configuration of an object storage (bucket)
func (*Session) GetObjectStorageLocation ¶ added in v0.5.1
func (s *Session) GetObjectStorageLocation(nsId string, osId string) (tbmodel.ObjectStorageLocationResponse, error)
GetObjectStorageLocation retrieves the location of an object storage (bucket)
func (*Session) GetObjectStorageSupport ¶ added in v0.5.1
func (s *Session) GetObjectStorageSupport(cspType string) (tbmodel.ObjectStorageSupportResponse, error)
GetObjectStorageSupport retrieves CSP support information for object storage features If cspType is empty, returns support information for all CSPs
func (*Session) GetObjectStorageVersioning ¶ added in v0.5.1
func (s *Session) GetObjectStorageVersioning(nsId string, osId string) (tbmodel.ObjectStorageGetVersioningResponse, error)
GetObjectStorageVersioning retrieves the versioning configuration of an object storage (bucket)
func (*Session) GetStorageObject ¶ added in v0.5.1
GetStorageObject retrieves metadata of a specific object in an object storage bucket.
func (*Session) InfraRecommendSpec ¶ added in v0.5.1
InfraRecommendSpec finds appropriate VM specs by filtering and prioritzing.
func (*Session) ListNlbs ¶ added in v0.5.3
func (s *Session) ListNlbs(nsId, infraId string) (NLBListResponse, error)
ListNlbs retrieves all NLBs in the specified namespace and infra.
func (*Session) ListObjectStorageObjects ¶ added in v0.5.1
func (s *Session) ListObjectStorageObjects(nsId string, osId string) (tbmodel.ObjectStorageListObjectsResponse, error)
ListObjectStorageObjects lists objects in a specific object storage bucket.
func (*Session) ListObjectStorages ¶ added in v0.5.1
func (s *Session) ListObjectStorages(nsId string, option string, filterKey string, filterVal string) (tbmodel.ObjectStorageListResponse, error)
ListObjectStorages retrieves the list of all object storages (buckets) in a namespace
func (*Session) ReadAllInfra ¶ added in v0.5.1
func (s *Session) ReadAllInfra(nsId string) (TbInfraInfoList, error)
ReadAllInfra retrieves all Infras (Infrastructure) in the specified namespace
func (*Session) ReadInfra ¶ added in v0.5.1
ReadInfra retrieves information about a specific Infra (Infrastructure) in the specified namespace
func (*Session) ReadInfraAccessInfo ¶ added in v0.5.1
func (s *Session) ReadInfraAccessInfo(nsId, infraId, option, accessInfoOption string) (tbmodel.InfraAccessInfo, error)
func (*Session) ReadInfraIDs ¶ added in v0.5.1
func (*Session) ReadNamespace ¶ added in v0.5.1
ReadNamespace retrieves information about a specific namespace
func (*Session) ReadRegionInfo ¶ added in v0.5.1
func (s *Session) ReadRegionInfo(providerName string, regionName string) (tbmodel.RegionDetail, error)
ReadRegionInfo reads region information in a specific provider
func (*Session) ReadSecurityGroup ¶ added in v0.5.1
func (s *Session) ReadSecurityGroup(nsId, securityGroupId string) (tbmodel.SecurityGroupInfo, error)
ReadSecurityGroup retrieves information about a specific Security Group in the specified namespace
func (*Session) ReadSshKey ¶ added in v0.5.1
func (s *Session) ReadSshKey(nsId, sshKeyId string) (tbmodel.SshKeyInfo, error)
ReadSshKey retrieves information about a specific SSH Key in the specified namespace
func (*Session) ReadVNet ¶ added in v0.5.1
ReadVNet retrieves information about a specific Virtual Network (VNet) in the specified namespace
func (*Session) ReadVmOsImage ¶ added in v0.5.1
ReadVmOsImage retrieves information about a specific VM OS Image in the specified namespace
func (*Session) ReadVmSpec ¶ added in v0.5.1
ReadVmSpec retrieves information about a specific VM Spec in the specified namespace
func (*Session) ReviewSpecImagePair ¶ added in v0.5.1
func (s *Session) ReviewSpecImagePair(req tbmodel.SpecImagePairReviewReq) (tbmodel.SpecImagePairReviewResult, error)
ReviewSpecImagePair calls POST /specImagePairReview to validate a spec-image pair and resolve the latest CSP image name (e.g., Alibaba ImageFamily resolution).
func (*Session) SearchVmOsImage ¶ added in v0.5.1
func (s *Session) SearchVmOsImage(nsId string, searchImageReq tbmodel.SearchImageRequest) (tbmodel.SearchImageResponse, error)
SearchVmOsImage searches VM OS images
func (*Session) SetCacheDuration ¶ added in v0.5.1
SetCacheDuration sets the cache duration for the request.
func (*Session) SetContext ¶ added in v0.5.1
SetContext sets the context for the request.
func (*Session) SetHeaders ¶ added in v0.5.1
SetHeaders sets multiple headers.
func (*Session) SetObjectStorageCORS ¶ added in v0.5.1
func (s *Session) SetObjectStorageCORS(nsId string, osId string, req tbmodel.ObjectStorageSetCorsRequest) error
SetObjectStorageCORS sets the CORS configuration of an object storage (bucket)
func (*Session) SetObjectStorageVersioning ¶ added in v0.5.1
func (s *Session) SetObjectStorageVersioning(nsId string, osId string, req tbmodel.ObjectStorageSetVersioningRequest) error
SetObjectStorageVersioning sets the versioning configuration of an object storage (bucket)
func (*Session) SetQueryParam ¶ added in v0.5.1
SetQueryParam sets a single query parameter.
func (*Session) SetQueryParams ¶ added in v0.5.1
SetQueryParams sets multiple query parameters.
func (*Session) SetResult ¶ added in v0.5.1
SetResult sets the result object to unmarshal the response into.
func (*Session) SetTraceInfo ¶ added in v0.5.1
SetTraceInfo injects the OpenTelemetry trace context into the request headers. This enables distributed tracing by propagating the trace ID and span ID to the Tumblebug API. It uses the global TextMapPropagator to ensure compatibility with the configured tracing backend.
Note: This method modifies the request headers in-place (merging with existing headers). It does not affect the request context or other headers, so it is safe to call regardless of the order of SetHeader or SetContext.
type TbInfraInfoList ¶ added in v0.5.1
type TumblebugClient ¶
type TumblebugClient struct {
// contains filtered or unexported fields
}
TumblebugClient is the factory for creating request sessions. It holds the shared configuration and connection pool.
func NewClient ¶
func NewClient(cfg ApiConfig) *TumblebugClient
NewClient creates a new TumblebugClient instance.
func NewDefaultClient ¶
func NewDefaultClient() *TumblebugClient
NewDefaultClient creates a new default client.
func (*TumblebugClient) NewSession ¶ added in v0.5.1
func (c *TumblebugClient) NewSession() *Session
NewSession creates a new Session for making requests.
type TumblebugTransport ¶ added in v0.5.1
type TumblebugTransport struct {
Transport http.RoundTripper
CacheDuration time.Duration
}
TumblebugTransport is a custom http.RoundTripper that adds caching and circuit breaker logic.