generated from hashicorp/terraform-provider-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 41
/
session.go
46 lines (37 loc) · 1.13 KB
/
session.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
package internal
import (
"context"
"github.com/harness/harness-go-sdk/harness/cd"
"github.com/harness/harness-go-sdk/harness/nextgen"
"github.com/harness/harness-go-sdk/harness/policymgmt"
openapi_client_nextgen "github.com/harness/harness-openapi-go-client/nextgen"
)
type Session struct {
AccountId string
Endpoint string
CDClient *cd.ApiClient
PLClient *nextgen.APIClient
Client *openapi_client_nextgen.APIClient
}
func (s *Session) GetPlatformClient() (*nextgen.APIClient, context.Context) {
return s.GetPlatformClientWithContext(nil)
}
func (s *Session) GetPlatformClientWithContext(ctx context.Context) (*nextgen.APIClient, context.Context) {
if ctx == nil {
ctx = context.Background()
}
return s.PLClient.WithAuthContext(ctx)
}
func (s *Session) GetClientWithContext(ctx context.Context) (*openapi_client_nextgen.APIClient, context.Context) {
if ctx == nil {
ctx = context.Background()
}
return s.Client.WithAuthContext(ctx)
}
func (s *Session) GetPolicyManagementClient() *policymgmt.APIClient {
c := policymgmt.NewAPIClient(
policymgmt.NewConfiguration(),
)
c.ChangeBasePath(s.Endpoint + "/pm")
return c
}