v1.0.0
This commit is contained in:
commit
e7f605ec8c
292 files changed
+43992
No files matched your search
@@ -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/BASIS/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)
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package core
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// HTTPError is returned for a non-2xx HTTP response.
|
||||
type HTTPError struct {
|
||||
StatusCode int
|
||||
Header http.Header
|
||||
Body []byte
|
||||
}
|
||||
|
||||
func (e *HTTPError) Error() string {
|
||||
status := fmt.Sprintf("HTTP %d", e.StatusCode)
|
||||
if statusText := http.StatusText(e.StatusCode); statusText != "" {
|
||||
status += " " + statusText
|
||||
}
|
||||
if len(e.Body) == 0 {
|
||||
return status
|
||||
}
|
||||
return status + ": " + string(e.Body)
|
||||
}
|
||||
|
||||
// BackendError is returned when the backend reports an error in an otherwise
|
||||
// successful HTTP response.
|
||||
type BackendError struct {
|
||||
Code int64
|
||||
Message string
|
||||
}
|
||||
|
||||
func (e *BackendError) Error() string {
|
||||
return fmt.Sprintf("code: %v, message: %v", e.Code, e.Message)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package core
|
||||
|
||||
import "io"
|
||||
|
||||
// UploadFile describes a file part in a multipart request. The SDK reads from
|
||||
// Reader but does not close it.
|
||||
type UploadFile struct {
|
||||
Filename string
|
||||
Reader io.Reader
|
||||
}
|
||||
Reference in new issue
Block a user