Skip to content

Commit bfab880

Browse files
aakashg00llam36
andauthored
Aakash - Add Accept account request to SDK + support JWT for existing request methods (#73)
* implemented accept account request, changed existing account request methods to support jwt * added try catch to auth methods * implemented accept account request, changed existing account request methods to support jwt * added try catch to auth methods * fixed i think * updated to work with sdk changes * fix: merge internal folder from main --------- Co-authored-by: Long Lam <llam36@gatech.edu>
1 parent 26e6aef commit bfab880

6 files changed

Lines changed: 452 additions & 52 deletions

File tree

‎src/internal/apis/AuthApi.ts‎

Lines changed: 93 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import * as runtime from '../runtime';
1616
import type {
17+
AcceptAccountRequestResponseModel,
1718
GetAllApiKeysResponse,
1819
IssueApiKeyRequest,
1920
IssueApiKeyResponse,
@@ -23,6 +24,8 @@ import type {
2324
RequestNewAccountModel,
2425
} from '../models/index';
2526
import {
27+
AcceptAccountRequestResponseModelFromJSON,
28+
AcceptAccountRequestResponseModelToJSON,
2629
GetAllApiKeysResponseFromJSON,
2730
GetAllApiKeysResponseToJSON,
2831
IssueApiKeyRequestFromJSON,
@@ -39,6 +42,12 @@ import {
3942
RequestNewAccountModelToJSON,
4043
} from '../models/index';
4144

45+
export interface AuthControllerAcceptAccountRequestRequest {
46+
id: string;
47+
xUserPassword?: string;
48+
xUserEmail?: string;
49+
}
50+
4251
export interface AuthControllerCreateAccountRequestRequest {
4352
requestNewAccountModel: RequestNewAccountModel;
4453
}
@@ -51,8 +60,8 @@ export interface AuthControllerCreateApiKeyRequest {
5160

5261
export interface AuthControllerDeleteAccountRequestRequest {
5362
id: string;
54-
xUserPassword: string;
55-
xUserEmail: string;
63+
xUserPassword?: string;
64+
xUserEmail?: string;
5665
}
5766

5867
export interface AuthControllerDeleteApiKeyByIdRequest {
@@ -63,8 +72,15 @@ export interface AuthControllerDeleteApiKeyByIdRequest {
6372
}
6473

6574
export interface AuthControllerGetAllAccountRequestsRequest {
66-
xUserPassword: string;
67-
xUserEmail: string;
75+
xUserPassword?: string;
76+
xUserEmail?: string;
77+
}
78+
79+
export interface AuthControllerGetAllApiKeysRequest {
80+
offset?: number;
81+
limit?: number;
82+
xUserPassword?: string;
83+
xUserEmail?: string;
6884
}
6985

7086
export interface AuthControllerGetAllApiKeysRequest {
@@ -91,6 +107,78 @@ export interface AuthControllerTestAuthRequest {
91107
*
92108
*/
93109
export class AuthApi extends runtime.BaseAPI {
110+
/**
111+
* 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.
112+
* Accept an account request
113+
*/
114+
async authControllerAcceptAccountRequestRaw(
115+
requestParameters: AuthControllerAcceptAccountRequestRequest,
116+
initOverrides?: RequestInit | runtime.InitOverrideFunction
117+
): Promise<runtime.ApiResponse<AcceptAccountRequestResponseModel>> {
118+
if (requestParameters['id'] == null) {
119+
throw new runtime.RequiredError(
120+
'id',
121+
'Required parameter "id" was null or undefined when calling authControllerAcceptAccountRequest().'
122+
);
123+
}
124+
125+
const queryParameters: any = {};
126+
127+
const headerParameters: runtime.HTTPHeaders = {};
128+
129+
if (requestParameters['xUserPassword'] != null) {
130+
headerParameters['X-User-Password'] = String(
131+
requestParameters['xUserPassword']
132+
);
133+
}
134+
135+
if (requestParameters['xUserEmail'] != null) {
136+
headerParameters['X-User-Email'] = String(
137+
requestParameters['xUserEmail']
138+
);
139+
}
140+
141+
if (this.configuration && this.configuration.accessToken) {
142+
const token = this.configuration.accessToken;
143+
const tokenString = await token('API_Key', []);
144+
145+
if (tokenString) {
146+
headerParameters['Authorization'] = `Bearer ${tokenString}`;
147+
}
148+
}
149+
const response = await this.request(
150+
{
151+
path: `/auth/account-request/{id}/accept`.replace(
152+
`{${'id'}}`,
153+
encodeURIComponent(String(requestParameters['id']))
154+
),
155+
method: 'POST',
156+
headers: headerParameters,
157+
query: queryParameters,
158+
},
159+
initOverrides
160+
);
161+
162+
return new runtime.JSONApiResponse(response, (jsonValue) =>
163+
AcceptAccountRequestResponseModelFromJSON(jsonValue)
164+
);
165+
}
166+
167+
/**
168+
* 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.
169+
* Accept an account request
170+
*/
171+
async authControllerAcceptAccountRequest(
172+
requestParameters: AuthControllerAcceptAccountRequestRequest,
173+
initOverrides?: RequestInit | runtime.InitOverrideFunction
174+
): Promise<AcceptAccountRequestResponseModel> {
175+
const response = await this.authControllerAcceptAccountRequestRaw(
176+
requestParameters,
177+
initOverrides
178+
);
179+
return await response.value();
180+
}
181+
94182
/**
95183
* Allows a prospective user to submit a request for a new account. The request is stored and can be reviewed by an admin.
96184
* Submit a new account request
@@ -222,20 +310,6 @@ export class AuthApi extends runtime.BaseAPI {
222310
);
223311
}
224312

225-
if (requestParameters['xUserPassword'] == null) {
226-
throw new runtime.RequiredError(
227-
'xUserPassword',
228-
'Required parameter "xUserPassword" was null or undefined when calling authControllerDeleteAccountRequest().'
229-
);
230-
}
231-
232-
if (requestParameters['xUserEmail'] == null) {
233-
throw new runtime.RequiredError(
234-
'xUserEmail',
235-
'Required parameter "xUserEmail" was null or undefined when calling authControllerDeleteAccountRequest().'
236-
);
237-
}
238-
239313
const queryParameters: any = {};
240314

241315
const headerParameters: runtime.HTTPHeaders = {};
@@ -372,20 +446,6 @@ export class AuthApi extends runtime.BaseAPI {
372446
requestParameters: AuthControllerGetAllAccountRequestsRequest,
373447
initOverrides?: RequestInit | runtime.InitOverrideFunction
374448
): Promise<runtime.ApiResponse<NewAccountRequestsResponse>> {
375-
if (requestParameters['xUserPassword'] == null) {
376-
throw new runtime.RequiredError(
377-
'xUserPassword',
378-
'Required parameter "xUserPassword" was null or undefined when calling authControllerGetAllAccountRequests().'
379-
);
380-
}
381-
382-
if (requestParameters['xUserEmail'] == null) {
383-
throw new runtime.RequiredError(
384-
'xUserEmail',
385-
'Required parameter "xUserEmail" was null or undefined when calling authControllerGetAllAccountRequests().'
386-
);
387-
}
388-
389449
const queryParameters: any = {};
390450

391451
const headerParameters: runtime.HTTPHeaders = {};
@@ -430,7 +490,7 @@ export class AuthApi extends runtime.BaseAPI {
430490
* Retrieve all account requests
431491
*/
432492
async authControllerGetAllAccountRequests(
433-
requestParameters: AuthControllerGetAllAccountRequestsRequest,
493+
requestParameters: AuthControllerGetAllAccountRequestsRequest = {},
434494
initOverrides?: RequestInit | runtime.InitOverrideFunction
435495
): Promise<NewAccountRequestsResponse> {
436496
const response = await this.authControllerGetAllAccountRequestsRaw(
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/* tslint:disable */
2+
/* eslint-disable */
3+
/**
4+
* Juno
5+
* Juno Public API Docs
6+
*
7+
* The version of the OpenAPI document: 1.0
8+
*
9+
*
10+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11+
* https://openapi-generator.tech
12+
* Do not edit the class manually.
13+
*/
14+
15+
import { mapValues } from '../runtime';
16+
import type { AcceptAccountRequestResponseProject } from './AcceptAccountRequestResponseProject';
17+
import {
18+
AcceptAccountRequestResponseProjectFromJSON,
19+
AcceptAccountRequestResponseProjectFromJSONTyped,
20+
AcceptAccountRequestResponseProjectToJSON,
21+
} from './AcceptAccountRequestResponseProject';
22+
import type { AcceptAccountRequestResponseUser } from './AcceptAccountRequestResponseUser';
23+
import {
24+
AcceptAccountRequestResponseUserFromJSON,
25+
AcceptAccountRequestResponseUserFromJSONTyped,
26+
AcceptAccountRequestResponseUserToJSON,
27+
} from './AcceptAccountRequestResponseUser';
28+
29+
/**
30+
*
31+
* @export
32+
* @interface AcceptAccountRequestResponseModel
33+
*/
34+
export interface AcceptAccountRequestResponseModel {
35+
/**
36+
* The created user
37+
* @type {AcceptAccountRequestResponseUser}
38+
* @memberof AcceptAccountRequestResponseModel
39+
*/
40+
user: AcceptAccountRequestResponseUser;
41+
/**
42+
* The created or linked project (if applicable)
43+
* @type {AcceptAccountRequestResponseProject}
44+
* @memberof AcceptAccountRequestResponseModel
45+
*/
46+
project?: AcceptAccountRequestResponseProject;
47+
}
48+
49+
/**
50+
* Check if a given object implements the AcceptAccountRequestResponseModel interface.
51+
*/
52+
export function instanceOfAcceptAccountRequestResponseModel(
53+
value: object
54+
): value is AcceptAccountRequestResponseModel {
55+
if (!('user' in value) || value['user'] === undefined) return false;
56+
return true;
57+
}
58+
59+
export function AcceptAccountRequestResponseModelFromJSON(
60+
json: any
61+
): AcceptAccountRequestResponseModel {
62+
return AcceptAccountRequestResponseModelFromJSONTyped(json, false);
63+
}
64+
65+
export function AcceptAccountRequestResponseModelFromJSONTyped(
66+
json: any,
67+
ignoreDiscriminator: boolean
68+
): AcceptAccountRequestResponseModel {
69+
if (json == null) {
70+
return json;
71+
}
72+
return {
73+
user: AcceptAccountRequestResponseUserFromJSON(json['user']),
74+
project:
75+
json['project'] == null
76+
? undefined
77+
: AcceptAccountRequestResponseProjectFromJSON(json['project']),
78+
};
79+
}
80+
81+
export function AcceptAccountRequestResponseModelToJSON(
82+
value?: AcceptAccountRequestResponseModel | null
83+
): any {
84+
if (value == null) {
85+
return value;
86+
}
87+
return {
88+
user: AcceptAccountRequestResponseUserToJSON(value['user']),
89+
project: AcceptAccountRequestResponseProjectToJSON(value['project']),
90+
};
91+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/* tslint:disable */
2+
/* eslint-disable */
3+
/**
4+
* Juno
5+
* Juno Public API Docs
6+
*
7+
* The version of the OpenAPI document: 1.0
8+
*
9+
*
10+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11+
* https://openapi-generator.tech
12+
* Do not edit the class manually.
13+
*/
14+
15+
import { mapValues } from '../runtime';
16+
/**
17+
*
18+
* @export
19+
* @interface AcceptAccountRequestResponseProject
20+
*/
21+
export interface AcceptAccountRequestResponseProject {
22+
/**
23+
* Project ID
24+
* @type {number}
25+
* @memberof AcceptAccountRequestResponseProject
26+
*/
27+
id: number;
28+
/**
29+
* Project name
30+
* @type {string}
31+
* @memberof AcceptAccountRequestResponseProject
32+
*/
33+
name: string;
34+
}
35+
36+
/**
37+
* Check if a given object implements the AcceptAccountRequestResponseProject interface.
38+
*/
39+
export function instanceOfAcceptAccountRequestResponseProject(
40+
value: object
41+
): value is AcceptAccountRequestResponseProject {
42+
if (!('id' in value) || value['id'] === undefined) return false;
43+
if (!('name' in value) || value['name'] === undefined) return false;
44+
return true;
45+
}
46+
47+
export function AcceptAccountRequestResponseProjectFromJSON(
48+
json: any
49+
): AcceptAccountRequestResponseProject {
50+
return AcceptAccountRequestResponseProjectFromJSONTyped(json, false);
51+
}
52+
53+
export function AcceptAccountRequestResponseProjectFromJSONTyped(
54+
json: any,
55+
ignoreDiscriminator: boolean
56+
): AcceptAccountRequestResponseProject {
57+
if (json == null) {
58+
return json;
59+
}
60+
return {
61+
id: json['id'],
62+
name: json['name'],
63+
};
64+
}
65+
66+
export function AcceptAccountRequestResponseProjectToJSON(
67+
value?: AcceptAccountRequestResponseProject | null
68+
): any {
69+
if (value == null) {
70+
return value;
71+
}
72+
return {
73+
id: value['id'],
74+
name: value['name'],
75+
};
76+
}

0 commit comments

Comments
 (0)