-
Notifications
You must be signed in to change notification settings - Fork 7
/
configuration.go
53 lines (47 loc) · 1.36 KB
/
configuration.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"fmt"
"net/http"
"os"
"time"
"github.com/stackitcloud/stackit-sdk-go/core/config"
"github.com/stackitcloud/stackit-sdk-go/services/dns"
"github.com/stackitcloud/stackit-sdk-go/services/postgresql"
)
func main() {
// Create a new API client with a custom configuration
configuration := &config.Configuration{
DefaultHeader: make(map[string]string),
UserAgent: "OpenAPI-Generator/1.0.0/go",
Debug: false,
Servers: config.ServerConfigurations{
{
URL: "http://localhost:8080",
Description: "Localhost for dns_ZoneApi",
},
},
OperationServers: map[string]config.ServerConfigurations{},
HTTPClient: &http.Client{
Timeout: 10 * time.Second,
},
}
_, err := dns.NewAPIClient(config.WithCustomConfiguration(configuration))
if err != nil {
fmt.Fprintf(os.Stderr, "[DNS API] Creating API client: %v\n", err)
os.Exit(1)
}
// Create a new API client with custom endpoint, e.g. for accessing the QA environment
_, err = dns.NewAPIClient(config.WithEndpoint("www.api-qa-url.com"))
if err != nil {
fmt.Fprintf(os.Stderr, "[DNS API] Creating API client: %v\n", err)
os.Exit(1)
}
// Create a new API client for a regional API
_, err = postgresql.NewAPIClient(
config.WithRegion("eu01"),
)
if err != nil {
fmt.Fprintf(os.Stderr, "[PostgreSQL API] Creating API client: %v\n", err)
os.Exit(1)
}
}