@@ -9,39 +9,43 @@ import (
9
9
"github.com/influxdata/influxdb-client-go/domain"
10
10
)
11
11
12
- // AuthorizationsApi provides methods for organizing Authorization in a InfluxDB server
13
- type AuthorizationsApi interface {
12
+ // AuthorizationsAPI provides methods for organizing Authorization in a InfluxDB server
13
+ type AuthorizationsAPI interface {
14
14
// GetAuthorizations returns all authorizations
15
15
GetAuthorizations (ctx context.Context ) (* []domain.Authorization , error )
16
16
// FindAuthorizationsByUserName returns all authorizations for given userName
17
17
FindAuthorizationsByUserName (ctx context.Context , userName string ) (* []domain.Authorization , error )
18
- // FindAuthorizationsByUserId returns all authorizations for given userID
19
- FindAuthorizationsByUserId (ctx context.Context , userId string ) (* []domain.Authorization , error )
18
+ // FindAuthorizationsByUserID returns all authorizations for given userID
19
+ FindAuthorizationsByUserID (ctx context.Context , userID string ) (* []domain.Authorization , error )
20
20
// FindAuthorizationsByOrgName returns all authorizations for given organization name
21
21
FindAuthorizationsByOrgName (ctx context.Context , orgName string ) (* []domain.Authorization , error )
22
- // FindAuthorizationsByUserId returns all authorizations for given organization id
23
- FindAuthorizationsByOrgId (ctx context.Context , orgId string ) (* []domain.Authorization , error )
22
+ // FindAuthorizationsByOrgID returns all authorizations for given organization id
23
+ FindAuthorizationsByOrgID (ctx context.Context , orgID string ) (* []domain.Authorization , error )
24
24
// CreateAuthorization creates new authorization
25
25
CreateAuthorization (ctx context.Context , authorization * domain.Authorization ) (* domain.Authorization , error )
26
- // CreateAuthorizationWithOrgId creates new authorization with given permissions scoped to given orgId
27
- CreateAuthorizationWithOrgId (ctx context.Context , orgId string , permissions []domain.Permission ) (* domain.Authorization , error )
28
- // UpdateAuthorizationStatus updates status of authorization with authId
29
- UpdateAuthorizationStatus (ctx context.Context , authId string , status domain.AuthorizationUpdateRequestStatus ) (* domain.Authorization , error )
30
- // DeleteAuthorization deletes authorization with authId
31
- DeleteAuthorization (ctx context.Context , authId string ) error
26
+ // CreateAuthorizationWithOrgID creates new authorization with given permissions scoped to given orgID
27
+ CreateAuthorizationWithOrgID (ctx context.Context , orgID string , permissions []domain.Permission ) (* domain.Authorization , error )
28
+ // UpdateAuthorizationStatus updates status of authorization
29
+ UpdateAuthorizationStatus (ctx context.Context , authorization * domain.Authorization , status domain.AuthorizationUpdateRequestStatus ) (* domain.Authorization , error )
30
+ // UpdateAuthorizationStatusWithID updates status of authorization with authID
31
+ UpdateAuthorizationStatusWithID (ctx context.Context , authID string , status domain.AuthorizationUpdateRequestStatus ) (* domain.Authorization , error )
32
+ // DeleteAuthorization deletes authorization
33
+ DeleteAuthorization (ctx context.Context , authorization * domain.Authorization ) error
34
+ // DeleteAuthorization deletes authorization with authID
35
+ DeleteAuthorizationWithID (ctx context.Context , authID string ) error
32
36
}
33
37
34
- type authorizationsApiImpl struct {
38
+ type authorizationsAPI struct {
35
39
apiClient * domain.ClientWithResponses
36
40
}
37
41
38
- func NewAuthorizationApi (apiClient * domain.ClientWithResponses ) AuthorizationsApi {
39
- return & authorizationsApiImpl {
42
+ func NewAuthorizationsAPI (apiClient * domain.ClientWithResponses ) AuthorizationsAPI {
43
+ return & authorizationsAPI {
40
44
apiClient : apiClient ,
41
45
}
42
46
}
43
47
44
- func (a * authorizationsApiImpl ) GetAuthorizations (ctx context.Context ) (* []domain.Authorization , error ) {
48
+ func (a * authorizationsAPI ) GetAuthorizations (ctx context.Context ) (* []domain.Authorization , error ) {
45
49
authQuery := & domain.GetAuthorizationsParams {}
46
50
auths , err := a .listAuthorizations (ctx , authQuery )
47
51
if err != nil {
@@ -50,7 +54,7 @@ func (a *authorizationsApiImpl) GetAuthorizations(ctx context.Context) (*[]domai
50
54
return auths .Authorizations , nil
51
55
}
52
56
53
- func (a * authorizationsApiImpl ) FindAuthorizationsByUserName (ctx context.Context , userName string ) (* []domain.Authorization , error ) {
57
+ func (a * authorizationsAPI ) FindAuthorizationsByUserName (ctx context.Context , userName string ) (* []domain.Authorization , error ) {
54
58
authQuery := & domain.GetAuthorizationsParams {User : & userName }
55
59
auths , err := a .listAuthorizations (ctx , authQuery )
56
60
if err != nil {
@@ -59,16 +63,16 @@ func (a *authorizationsApiImpl) FindAuthorizationsByUserName(ctx context.Context
59
63
return auths .Authorizations , nil
60
64
}
61
65
62
- func (a * authorizationsApiImpl ) FindAuthorizationsByUserId (ctx context.Context , userId string ) (* []domain.Authorization , error ) {
63
- authQuery := & domain.GetAuthorizationsParams {UserID : & userId }
66
+ func (a * authorizationsAPI ) FindAuthorizationsByUserID (ctx context.Context , userID string ) (* []domain.Authorization , error ) {
67
+ authQuery := & domain.GetAuthorizationsParams {UserID : & userID }
64
68
auths , err := a .listAuthorizations (ctx , authQuery )
65
69
if err != nil {
66
70
return nil , err
67
71
}
68
72
return auths .Authorizations , nil
69
73
}
70
74
71
- func (a * authorizationsApiImpl ) FindAuthorizationsByOrgName (ctx context.Context , orgName string ) (* []domain.Authorization , error ) {
75
+ func (a * authorizationsAPI ) FindAuthorizationsByOrgName (ctx context.Context , orgName string ) (* []domain.Authorization , error ) {
72
76
authQuery := & domain.GetAuthorizationsParams {Org : & orgName }
73
77
auths , err := a .listAuthorizations (ctx , authQuery )
74
78
if err != nil {
@@ -77,16 +81,16 @@ func (a *authorizationsApiImpl) FindAuthorizationsByOrgName(ctx context.Context,
77
81
return auths .Authorizations , nil
78
82
}
79
83
80
- func (a * authorizationsApiImpl ) FindAuthorizationsByOrgId (ctx context.Context , orgId string ) (* []domain.Authorization , error ) {
81
- authQuery := & domain.GetAuthorizationsParams {OrgID : & orgId }
84
+ func (a * authorizationsAPI ) FindAuthorizationsByOrgID (ctx context.Context , orgID string ) (* []domain.Authorization , error ) {
85
+ authQuery := & domain.GetAuthorizationsParams {OrgID : & orgID }
82
86
auths , err := a .listAuthorizations (ctx , authQuery )
83
87
if err != nil {
84
88
return nil , err
85
89
}
86
90
return auths .Authorizations , nil
87
91
}
88
92
89
- func (a * authorizationsApiImpl ) listAuthorizations (ctx context.Context , query * domain.GetAuthorizationsParams ) (* domain.Authorizations , error ) {
93
+ func (a * authorizationsAPI ) listAuthorizations (ctx context.Context , query * domain.GetAuthorizationsParams ) (* domain.Authorizations , error ) {
90
94
if query == nil {
91
95
query = & domain.GetAuthorizationsParams {}
92
96
}
@@ -100,7 +104,7 @@ func (a *authorizationsApiImpl) listAuthorizations(ctx context.Context, query *d
100
104
return response .JSON200 , nil
101
105
}
102
106
103
- func (a * authorizationsApiImpl ) CreateAuthorization (ctx context.Context , authorization * domain.Authorization ) (* domain.Authorization , error ) {
107
+ func (a * authorizationsAPI ) CreateAuthorization (ctx context.Context , authorization * domain.Authorization ) (* domain.Authorization , error ) {
104
108
params := & domain.PostAuthorizationsParams {}
105
109
response , err := a .apiClient .PostAuthorizationsWithResponse (ctx , params , domain .PostAuthorizationsJSONRequestBody (* authorization ))
106
110
if err != nil {
@@ -115,20 +119,20 @@ func (a *authorizationsApiImpl) CreateAuthorization(ctx context.Context, authori
115
119
return response .JSON201 , nil
116
120
}
117
121
118
- func (a * authorizationsApiImpl ) CreateAuthorizationWithOrgId (ctx context.Context , orgId string , permissions []domain.Permission ) (* domain.Authorization , error ) {
122
+ func (a * authorizationsAPI ) CreateAuthorizationWithOrgID (ctx context.Context , orgID string , permissions []domain.Permission ) (* domain.Authorization , error ) {
119
123
status := domain .AuthorizationUpdateRequestStatusActive
120
124
auth := & domain.Authorization {
121
125
AuthorizationUpdateRequest : domain.AuthorizationUpdateRequest {Status : & status },
122
- OrgID : & orgId ,
126
+ OrgID : & orgID ,
123
127
Permissions : & permissions ,
124
128
}
125
129
return a .CreateAuthorization (ctx , auth )
126
130
}
127
131
128
- func (a * authorizationsApiImpl ) UpdateAuthorizationStatus (ctx context.Context , authId string , status domain.AuthorizationUpdateRequestStatus ) (* domain.Authorization , error ) {
132
+ func (a * authorizationsAPI ) UpdateAuthorizationStatusWithID (ctx context.Context , authID string , status domain.AuthorizationUpdateRequestStatus ) (* domain.Authorization , error ) {
129
133
params := & domain.PatchAuthorizationsIDParams {}
130
134
body := & domain.PatchAuthorizationsIDJSONRequestBody {Status : & status }
131
- response , err := a .apiClient .PatchAuthorizationsIDWithResponse (ctx , authId , params , * body )
135
+ response , err := a .apiClient .PatchAuthorizationsIDWithResponse (ctx , authID , params , * body )
132
136
if err != nil {
133
137
return nil , err
134
138
}
@@ -138,9 +142,17 @@ func (a *authorizationsApiImpl) UpdateAuthorizationStatus(ctx context.Context, a
138
142
return response .JSON200 , nil
139
143
}
140
144
141
- func (a * authorizationsApiImpl ) DeleteAuthorization (ctx context.Context , authId string ) error {
145
+ func (a * authorizationsAPI ) UpdateAuthorizationStatus (ctx context.Context , authorization * domain.Authorization , status domain.AuthorizationUpdateRequestStatus ) (* domain.Authorization , error ) {
146
+ return a .UpdateAuthorizationStatusWithID (ctx , * authorization .Id , status )
147
+ }
148
+
149
+ func (a * authorizationsAPI ) DeleteAuthorization (ctx context.Context , authorization * domain.Authorization ) error {
150
+ return a .DeleteAuthorizationWithID (ctx , * authorization .Id )
151
+ }
152
+
153
+ func (a * authorizationsAPI ) DeleteAuthorizationWithID (ctx context.Context , authID string ) error {
142
154
params := & domain.DeleteAuthorizationsIDParams {}
143
- response , err := a .apiClient .DeleteAuthorizationsIDWithResponse (ctx , authId , params )
155
+ response , err := a .apiClient .DeleteAuthorizationsIDWithResponse (ctx , authID , params )
144
156
if err != nil {
145
157
return err
146
158
}
0 commit comments