Skip to content

Commit f1bb0ac

Browse files
committed
implemented accept account request, changed existing account request methods to support jwt
1 parent 23248c1 commit f1bb0ac

6 files changed

Lines changed: 381 additions & 64 deletions

File tree

‎src/internal/api/authApi.ts‎

Lines changed: 120 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import localVarRequest from 'request';
1414
import http from 'http';
1515

1616
/* tslint:disable:no-unused-locals */
17+
import { AcceptAccountRequestResponseModel } from '../model/acceptAccountRequestResponseModel';
1718
import { IssueApiKeyRequest } from '../model/issueApiKeyRequest';
1819
import { IssueApiKeyResponse } from '../model/issueApiKeyResponse';
1920
import { IssueJWTResponse } from '../model/issueJWTResponse';
@@ -109,6 +110,121 @@ export class AuthApi {
109110
this.interceptors.push(interceptor);
110111
}
111112

113+
/**
114+
* Accepts a pending account request: creates the user, optionally creates/links a project (for ADMIN requests with a projectName), and deletes the pending request. Requires admin or superadmin credentials.
115+
* @summary Accept an account request
116+
* @param id ID of the account request to accept
117+
* @param xUserPassword Password of the admin or superadmin user
118+
* @param xUserEmail Email of an admin or superadmin user
119+
*/
120+
public async authControllerAcceptAccountRequest(
121+
id: string,
122+
xUserPassword?: string,
123+
xUserEmail?: string,
124+
options: { headers: { [name: string]: string } } = { headers: {} }
125+
): Promise<{
126+
response: http.IncomingMessage;
127+
body: AcceptAccountRequestResponseModel;
128+
}> {
129+
const localVarPath =
130+
this.basePath +
131+
'/auth/account-request/{id}/accept'.replace(
132+
'{' + 'id' + '}',
133+
encodeURIComponent(String(id))
134+
);
135+
let localVarQueryParameters: any = {};
136+
let localVarHeaderParams: any = (<any>Object).assign(
137+
{},
138+
this._defaultHeaders
139+
);
140+
const produces = ['application/json'];
141+
// give precedence to 'application/json'
142+
if (produces.indexOf('application/json') >= 0) {
143+
localVarHeaderParams.Accept = 'application/json';
144+
} else {
145+
localVarHeaderParams.Accept = produces.join(',');
146+
}
147+
let localVarFormParams: any = {};
148+
149+
// verify required parameter 'id' is not null or undefined
150+
if (id === null || id === undefined) {
151+
throw new Error(
152+
'Required parameter id was null or undefined when calling authControllerAcceptAccountRequest.'
153+
);
154+
}
155+
156+
localVarHeaderParams['X-User-Password'] = ObjectSerializer.serialize(
157+
xUserPassword,
158+
'string'
159+
);
160+
localVarHeaderParams['X-User-Email'] = ObjectSerializer.serialize(
161+
xUserEmail,
162+
'string'
163+
);
164+
(<any>Object).assign(localVarHeaderParams, options.headers);
165+
166+
let localVarUseFormData = false;
167+
168+
let localVarRequestOptions: localVarRequest.Options = {
169+
method: 'POST',
170+
qs: localVarQueryParameters,
171+
headers: localVarHeaderParams,
172+
uri: localVarPath,
173+
useQuerystring: this._useQuerystring,
174+
json: true,
175+
};
176+
177+
let authenticationPromise = Promise.resolve();
178+
if (this.authentications.API_Key.accessToken) {
179+
authenticationPromise = authenticationPromise.then(() =>
180+
this.authentications.API_Key.applyToRequest(localVarRequestOptions)
181+
);
182+
}
183+
authenticationPromise = authenticationPromise.then(() =>
184+
this.authentications.default.applyToRequest(localVarRequestOptions)
185+
);
186+
187+
let interceptorPromise = authenticationPromise;
188+
for (const interceptor of this.interceptors) {
189+
interceptorPromise = interceptorPromise.then(() =>
190+
interceptor(localVarRequestOptions)
191+
);
192+
}
193+
194+
return interceptorPromise.then(() => {
195+
if (Object.keys(localVarFormParams).length) {
196+
if (localVarUseFormData) {
197+
(<any>localVarRequestOptions).formData = localVarFormParams;
198+
} else {
199+
localVarRequestOptions.form = localVarFormParams;
200+
}
201+
}
202+
return new Promise<{
203+
response: http.IncomingMessage;
204+
body: AcceptAccountRequestResponseModel;
205+
}>((resolve, reject) => {
206+
localVarRequest(localVarRequestOptions, (error, response, body) => {
207+
if (error) {
208+
reject(error);
209+
} else {
210+
if (
211+
response.statusCode &&
212+
response.statusCode >= 200 &&
213+
response.statusCode <= 299
214+
) {
215+
body = ObjectSerializer.deserialize(
216+
body,
217+
'AcceptAccountRequestResponseModel'
218+
);
219+
resolve({ response: response, body: body });
220+
} else {
221+
reject(new HttpError(response, body, response.statusCode));
222+
}
223+
}
224+
});
225+
});
226+
});
227+
}
112228
/**
113229
* Allows a prospective user to submit a request for a new account. The request is stored and can be reviewed by an admin.
114230
* @summary Submit a new account request
@@ -335,8 +451,8 @@ export class AuthApi {
335451
*/
336452
public async authControllerDeleteAccountRequest(
337453
id: string,
338-
xUserPassword: string,
339-
xUserEmail: string,
454+
xUserPassword?: string,
455+
xUserEmail?: string,
340456
options: { headers: { [name: string]: string } } = { headers: {} }
341457
): Promise<{
342458
response: http.IncomingMessage;
@@ -369,20 +485,6 @@ export class AuthApi {
369485
);
370486
}
371487

372-
// verify required parameter 'xUserPassword' is not null or undefined
373-
if (xUserPassword === null || xUserPassword === undefined) {
374-
throw new Error(
375-
'Required parameter xUserPassword was null or undefined when calling authControllerDeleteAccountRequest.'
376-
);
377-
}
378-
379-
// verify required parameter 'xUserEmail' is not null or undefined
380-
if (xUserEmail === null || xUserEmail === undefined) {
381-
throw new Error(
382-
'Required parameter xUserEmail was null or undefined when calling authControllerDeleteAccountRequest.'
383-
);
384-
}
385-
386488
localVarHeaderParams['X-User-Password'] = ObjectSerializer.serialize(
387489
xUserPassword,
388490
'string'
@@ -549,8 +651,8 @@ export class AuthApi {
549651
* @param xUserEmail Email of an admin or superadmin user
550652
*/
551653
public async authControllerGetAllAccountRequests(
552-
xUserPassword: string,
553-
xUserEmail: string,
654+
xUserPassword?: string,
655+
xUserEmail?: string,
554656
options: { headers: { [name: string]: string } } = { headers: {} }
555657
): Promise<{
556658
response: http.IncomingMessage;
@@ -571,20 +673,6 @@ export class AuthApi {
571673
}
572674
let localVarFormParams: any = {};
573675

574-
// verify required parameter 'xUserPassword' is not null or undefined
575-
if (xUserPassword === null || xUserPassword === undefined) {
576-
throw new Error(
577-
'Required parameter xUserPassword was null or undefined when calling authControllerGetAllAccountRequests.'
578-
);
579-
}
580-
581-
// verify required parameter 'xUserEmail' is not null or undefined
582-
if (xUserEmail === null || xUserEmail === undefined) {
583-
throw new Error(
584-
'Required parameter xUserEmail was null or undefined when calling authControllerGetAllAccountRequests.'
585-
);
586-
}
587-
588676
localVarHeaderParams['X-User-Password'] = ObjectSerializer.serialize(
589677
xUserPassword,
590678
'string'
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Juno
3+
* Juno Public API Docs
4+
*
5+
* The version of the OpenAPI document: 1.0
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
13+
import { RequestFile } from './models';
14+
import { AcceptAccountRequestResponseProject } from './acceptAccountRequestResponseProject';
15+
import { AcceptAccountRequestResponseUser } from './acceptAccountRequestResponseUser';
16+
17+
export class AcceptAccountRequestResponseModel {
18+
/**
19+
* The created user
20+
*/
21+
'user': AcceptAccountRequestResponseUser;
22+
/**
23+
* The created or linked project (if applicable)
24+
*/
25+
'project'?: AcceptAccountRequestResponseProject;
26+
27+
static discriminator: string | undefined = undefined;
28+
29+
static attributeTypeMap: Array<{
30+
name: string;
31+
baseName: string;
32+
type: string;
33+
}> = [
34+
{
35+
name: 'user',
36+
baseName: 'user',
37+
type: 'AcceptAccountRequestResponseUser',
38+
},
39+
{
40+
name: 'project',
41+
baseName: 'project',
42+
type: 'AcceptAccountRequestResponseProject',
43+
},
44+
];
45+
46+
static getAttributeTypeMap() {
47+
return AcceptAccountRequestResponseModel.attributeTypeMap;
48+
}
49+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* Juno
3+
* Juno Public API Docs
4+
*
5+
* The version of the OpenAPI document: 1.0
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
13+
import { RequestFile } from './models';
14+
15+
export class AcceptAccountRequestResponseProject {
16+
/**
17+
* Project ID
18+
*/
19+
'id': number;
20+
/**
21+
* Project name
22+
*/
23+
'name': string;
24+
25+
static discriminator: string | undefined = undefined;
26+
27+
static attributeTypeMap: Array<{
28+
name: string;
29+
baseName: string;
30+
type: string;
31+
}> = [
32+
{
33+
name: 'id',
34+
baseName: 'id',
35+
type: 'number',
36+
},
37+
{
38+
name: 'name',
39+
baseName: 'name',
40+
type: 'string',
41+
},
42+
];
43+
44+
static getAttributeTypeMap() {
45+
return AcceptAccountRequestResponseProject.attributeTypeMap;
46+
}
47+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/**
2+
* Juno
3+
* Juno Public API Docs
4+
*
5+
* The version of the OpenAPI document: 1.0
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
13+
import { RequestFile } from './models';
14+
15+
export class AcceptAccountRequestResponseUser {
16+
/**
17+
* User ID
18+
*/
19+
'id': number;
20+
/**
21+
* Email
22+
*/
23+
'email': string;
24+
/**
25+
* Name
26+
*/
27+
'name': string;
28+
/**
29+
* User type
30+
*/
31+
'type': AcceptAccountRequestResponseUser.TypeEnum;
32+
/**
33+
* Project IDs the user is linked to
34+
*/
35+
'projectIds'?: Array<number>;
36+
37+
static discriminator: string | undefined = undefined;
38+
39+
static attributeTypeMap: Array<{
40+
name: string;
41+
baseName: string;
42+
type: string;
43+
}> = [
44+
{
45+
name: 'id',
46+
baseName: 'id',
47+
type: 'number',
48+
},
49+
{
50+
name: 'email',
51+
baseName: 'email',
52+
type: 'string',
53+
},
54+
{
55+
name: 'name',
56+
baseName: 'name',
57+
type: 'string',
58+
},
59+
{
60+
name: 'type',
61+
baseName: 'type',
62+
type: 'AcceptAccountRequestResponseUser.TypeEnum',
63+
},
64+
{
65+
name: 'projectIds',
66+
baseName: 'projectIds',
67+
type: 'Array<number>',
68+
},
69+
];
70+
71+
static getAttributeTypeMap() {
72+
return AcceptAccountRequestResponseUser.attributeTypeMap;
73+
}
74+
}
75+
76+
export namespace AcceptAccountRequestResponseUser {
77+
export enum TypeEnum {
78+
Superadmin = <any>'SUPERADMIN',
79+
Admin = <any>'ADMIN',
80+
User = <any>'USER',
81+
}
82+
}

0 commit comments

Comments
 (0)