This commit is contained in:
stSolo
2022-12-22 17:56:47 +03:00
parent 8712561853
commit d4b1ab7133
672 changed files with 28509 additions and 4419 deletions

View File

@@ -15,31 +15,36 @@ import (
"github.com/rudecs/decort-sdk/internal/client"
)
type Client struct {
// HTTP-client for platform
type DecortClient struct {
decortURL string
client *http.Client
}
func New(cfg config.Config) *Client {
// Сlient builder
func New(cfg config.Config) *DecortClient {
if cfg.Retries == 0 {
cfg.Retries = 5
}
return &Client{
return &DecortClient{
decortURL: cfg.DecortURL,
client: client.NewHttpClient(cfg),
}
}
func (dc *Client) CloudApi() *cloudapi.CloudApi {
// CloudAPI builder
func (dc *DecortClient) CloudAPI() *cloudapi.CloudAPI {
return cloudapi.New(dc)
}
func (dc *Client) CloudBroker() *cloudbroker.CloudBroker {
// CloudBroker builder
func (dc *DecortClient) CloudBroker() *cloudbroker.CloudBroker {
return cloudbroker.New(dc)
}
func (dc *Client) DecortApiCall(ctx context.Context, method, url string, params interface{}) ([]byte, error) {
// DecortApiCall method for sending requests to the platform
func (dc *DecortClient) DecortApiCall(ctx context.Context, method, url string, params interface{}) ([]byte, error) {
values, err := query.Values(params)
if err != nil {
return nil, err