This commit is contained in:
q committed 2026-08-26 17:05:17 +03:00
commit 6ba17b144c
292 files changed
+43992

No files matched your search

+104
View File
@@ -0,0 +1,104 @@
// Code generated by internal codegen utility; DO NOT EDIT.
package core
import (
"maps"
"net/http"
"runtime/debug"
"strings"
"sync"
)
const sdkModulePath = "repository.basistech.ru/de-golang-sdk"
type Configuration struct {
ServerURL string `json:"serverURL,omitempty"`
UserAgent string `json:"userAgent,omitempty"`
HTTPClient *http.Client
// SkipCompatibilityCheck disables the automatic compatibility checks performed during authentication.
//
// It does not affect explicit CheckCompatibility calls.
SkipCompatibilityCheck bool `json:"skipCompatibilityCheck,omitempty"`
defaultHeaderMu sync.RWMutex
defaultHeader map[string]string
}
func NewConfiguration() *Configuration {
return &Configuration{
defaultHeader: make(map[string]string),
UserAgent: "de-golang-sdk/" + SDKVersion(),
}
}
// Clone returns an independent configuration copy. The HTTP client is shared,
// while the default headers use independent storage and synchronization.
func (c *Configuration) Clone() *Configuration {
if c == nil {
return nil
}
c.defaultHeaderMu.RLock()
defer c.defaultHeaderMu.RUnlock()
return &Configuration{
ServerURL: c.ServerURL,
UserAgent: c.UserAgent,
HTTPClient: c.HTTPClient,
SkipCompatibilityCheck: c.SkipCompatibilityCheck,
defaultHeader: maps.Clone(c.defaultHeader),
}
}
// SDKVersion returns the module version embedded in the running program.
func SDKVersion() string {
buildInfo, ok := debug.ReadBuildInfo()
if !ok {
return "devel"
}
return sdkVersionFromBuildInfo(buildInfo)
}
func sdkVersionFromBuildInfo(buildInfo *debug.BuildInfo) string {
if buildInfo == nil {
return "devel"
}
modules := append([]*debug.Module{&buildInfo.Main}, buildInfo.Deps...)
for _, module := range modules {
if module == nil || module.Path != sdkModulePath {
continue
}
if module.Replace != nil {
module = module.Replace
}
version := strings.TrimPrefix(module.Version, "v")
if version == "" || version == "(devel)" {
return "devel"
}
return version
}
return "devel"
}
func (c *Configuration) AddDefaultHeader(key, value string) {
c.defaultHeaderMu.Lock()
defer c.defaultHeaderMu.Unlock()
if c.defaultHeader == nil {
c.defaultHeader = make(map[string]string)
}
c.defaultHeader[http.CanonicalHeaderKey(key)] = value
}
func (c *Configuration) DefaultHeaders() map[string]string {
c.defaultHeaderMu.RLock()
defer c.defaultHeaderMu.RUnlock()
return maps.Clone(c.defaultHeader)
}