-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathclient.go
75 lines (58 loc) · 2.86 KB
/
client.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
IdentityNow V3 API
Use these APIs to interact with the IdentityNow platform to achieve repeatable, automated processes with greater scalability. We encourage you to join the SailPoint Developer Community forum at https://developer.sailpoint.com/discuss to connect with other developers using our APIs.
API version: 3.0.0
*/
package sailpoint
import (
"regexp"
"github.com/hashicorp/go-retryablehttp"
beta "github.com/sailpoint-oss/golang-sdk/v2/api_beta"
generic "github.com/sailpoint-oss/golang-sdk/v2/api_generic"
v2024 "github.com/sailpoint-oss/golang-sdk/v2/api_v2024"
v3 "github.com/sailpoint-oss/golang-sdk/v2/api_v3"
)
var (
jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?json)`)
xmlCheck = regexp.MustCompile(`(?i:(?:application|text)/xml)`)
)
// APIClient manages communication with the IdentityNow V3 API API v3.0.0
// In most cases there should be only one, shared, APIClient.
type APIClient struct {
cfg *Configuration
common service // Reuse a single struct instead of allocating one for each service on the heap.
// API Services
V3 *v3.APIClient
Beta *beta.APIClient
V2024 *v2024.APIClient
Generic *generic.APIClient
token string
}
type service struct {
client *v3.APIClient
betaClient *beta.APIClient
v2024Client *v2024.APIClient
genericClient *generic.APIClient
}
// NewAPIClient creates a new API client. Requires a userAgent string describing your application.
// optionally a custom http.Client to allow for advanced features such as caching.
func NewAPIClient(cfg *Configuration) *APIClient {
if cfg.HTTPClient == nil {
cfg.HTTPClient = retryablehttp.NewClient()
}
c := &APIClient{}
CV3 := v3.NewConfiguration(cfg.ClientConfiguration.ClientId, cfg.ClientConfiguration.ClientSecret, cfg.ClientConfiguration.BaseURL+"/v3", cfg.ClientConfiguration.TokenURL, cfg.ClientConfiguration.Token, cfg.Experimental)
CBeta := beta.NewConfiguration(cfg.ClientConfiguration.ClientId, cfg.ClientConfiguration.ClientSecret, cfg.ClientConfiguration.BaseURL+"/beta", cfg.ClientConfiguration.TokenURL, cfg.ClientConfiguration.Token, cfg.Experimental)
CV2024 := v2024.NewConfiguration(cfg.ClientConfiguration.ClientId, cfg.ClientConfiguration.ClientSecret, cfg.ClientConfiguration.BaseURL+"/v2024", cfg.ClientConfiguration.TokenURL, cfg.ClientConfiguration.Token, cfg.Experimental)
CVGeneric := generic.NewConfiguration(cfg.ClientConfiguration.ClientId, cfg.ClientConfiguration.ClientSecret, cfg.ClientConfiguration.BaseURL, cfg.ClientConfiguration.TokenURL, cfg.ClientConfiguration.Token, cfg.Experimental)
CV3.HTTPClient = cfg.HTTPClient
CBeta.HTTPClient = cfg.HTTPClient
CV2024.HTTPClient = cfg.HTTPClient
CVGeneric.HTTPClient = cfg.HTTPClient
c.V3 = v3.NewAPIClient(CV3)
c.Beta = beta.NewAPIClient(CBeta)
c.V2024 = v2024.NewAPIClient(CV2024)
c.Generic = generic.NewAPIClient(CVGeneric)
// API Services
return c
}