generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 13
/
facade_security_trust.go
132 lines (103 loc) · 5.65 KB
/
facade_security_trust.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package btpcli
import (
"context"
"github.com/SAP/terraform-provider-btp/internal/btpcli/types/xsuaa_trust"
"github.com/SAP/terraform-provider-btp/internal/tfutils"
)
func newSecurityTrustFacade(cliClient *v2Client) securityTrustFacade {
return securityTrustFacade{cliClient: cliClient}
}
type securityTrustFacade struct {
cliClient *v2Client
}
func (f *securityTrustFacade) getCommand() string {
return "security/trust"
}
func (f *securityTrustFacade) ListByGlobalAccount(ctx context.Context) (xsuaa_trust.TrustConfigurationResponseCollectionObject, CommandResponse, error) {
return doExecute[xsuaa_trust.TrustConfigurationResponseCollectionObject](f.cliClient, ctx, NewListRequest(f.getCommand(), map[string]string{
"globalAccount": f.cliClient.GetGlobalAccountSubdomain(),
}))
}
func (f *securityTrustFacade) GetByGlobalAccount(ctx context.Context, origin string) (xsuaa_trust.TrustConfigurationResponseObject, CommandResponse, error) {
return doExecute[xsuaa_trust.TrustConfigurationResponseObject](f.cliClient, ctx, NewGetRequest(f.getCommand(), map[string]string{
"globalAccount": f.cliClient.GetGlobalAccountSubdomain(),
"origin": origin,
}))
}
func (f *securityTrustFacade) ListBySubaccount(ctx context.Context, subaccountId string) (xsuaa_trust.TrustConfigurationResponseCollectionObject, CommandResponse, error) {
return doExecute[xsuaa_trust.TrustConfigurationResponseCollectionObject](f.cliClient, ctx, NewListRequest(f.getCommand(), map[string]string{
"subaccount": subaccountId,
}))
}
func (f *securityTrustFacade) GetBySubaccount(ctx context.Context, subaccountId string, origin string) (xsuaa_trust.TrustConfigurationResponseObject, CommandResponse, error) {
return doExecute[xsuaa_trust.TrustConfigurationResponseObject](f.cliClient, ctx, NewGetRequest(f.getCommand(), map[string]string{
"subaccount": subaccountId,
"origin": origin,
}))
}
type TrustConfigurationCreateInput struct {
IdentityProvider string `btpcli:"iasTenantUrl"`
Name *string `btpcli:"name"`
Description *string `btpcli:"description"`
Origin *string `btpcli:"origin"`
Domain *string `btpcli:"domain"`
}
func (f *securityTrustFacade) CreateByGlobalAccount(ctx context.Context, args TrustConfigurationCreateInput) (xsuaa_trust.ModifyTrustConfigurationResponseObject, CommandResponse, error) {
params, err := tfutils.ToBTPCLIParamsMap(args)
if err != nil {
return xsuaa_trust.ModifyTrustConfigurationResponseObject{}, CommandResponse{}, err
}
params["globalAccount"] = f.cliClient.GetGlobalAccountSubdomain()
return doExecute[xsuaa_trust.ModifyTrustConfigurationResponseObject](f.cliClient, ctx, NewCreateRequest(f.getCommand(), params))
}
func (f *securityTrustFacade) CreateBySubaccount(ctx context.Context, subaccountId string, args TrustConfigurationCreateInput) (xsuaa_trust.ModifyTrustConfigurationResponseObject, CommandResponse, error) {
params, err := tfutils.ToBTPCLIParamsMap(args)
if err != nil {
return xsuaa_trust.ModifyTrustConfigurationResponseObject{}, CommandResponse{}, err
}
params["subaccount"] = subaccountId
return doExecute[xsuaa_trust.ModifyTrustConfigurationResponseObject](f.cliClient, ctx, NewCreateRequest(f.getCommand(), params))
}
type TrustConfigurationUpdateInput struct {
OriginKey string `btpcli:"originKey"`
IdentityProvider *string `btpcli:"iasTenantUrl"`
Name *string `btpcli:"name"`
Description *string `btpcli:"description"`
Domain *string `btpcli:"domain"`
LinkText *string `btpcli:"linkText"` // subaccount only
AvailableForUserLogon *bool `btpcli:"userLogon"` // subaccount only
AutoCreateShadowUsers *bool `btpcli:"shadowUsers"` // subaccount only
Status *string `btpcli:"status"`
}
func (f *securityTrustFacade) UpdateByGlobalAccount(ctx context.Context, args TrustConfigurationUpdateInput) (xsuaa_trust.TrustConfigurationResponseObject, CommandResponse, error) {
params, err := tfutils.ToBTPCLIParamsMap(args)
if err != nil {
return xsuaa_trust.TrustConfigurationResponseObject{}, CommandResponse{}, err
}
params["globalAccount"] = f.cliClient.GetGlobalAccountSubdomain()
params["refreshTrust"] = "true"
return doExecute[xsuaa_trust.TrustConfigurationResponseObject](f.cliClient, ctx, NewUpdateRequest(f.getCommand(), params))
}
func (f *securityTrustFacade) UpdateBySubaccount(ctx context.Context, subaccountId string, args TrustConfigurationUpdateInput) (xsuaa_trust.TrustConfigurationResponseObject, CommandResponse, error) {
params, err := tfutils.ToBTPCLIParamsMap(args)
if err != nil {
return xsuaa_trust.TrustConfigurationResponseObject{}, CommandResponse{}, err
}
params["subaccount"] = subaccountId
params["refreshTrust"] = "true"
return doExecute[xsuaa_trust.TrustConfigurationResponseObject](f.cliClient, ctx, NewUpdateRequest(f.getCommand(), params))
}
func (f *securityTrustFacade) DeleteByGlobalAccount(ctx context.Context, originKey string) (xsuaa_trust.ModifyTrustConfigurationResponseObject, CommandResponse, error) {
return doExecute[xsuaa_trust.ModifyTrustConfigurationResponseObject](f.cliClient, ctx, NewDeleteRequest(f.getCommand(), map[string]string{
"globalAccount": f.cliClient.GetGlobalAccountSubdomain(),
"originKey": originKey,
"confirm": "true",
}))
}
func (f *securityTrustFacade) DeleteBySubaccount(ctx context.Context, subaccountId string, originKey string) (xsuaa_trust.ModifyTrustConfigurationResponseObject, CommandResponse, error) {
return doExecute[xsuaa_trust.ModifyTrustConfigurationResponseObject](f.cliClient, ctx, NewDeleteRequest(f.getCommand(), map[string]string{
"subaccount": subaccountId,
"originKey": originKey,
"confirm": "true",
}))
}