Skip to content

Commit 531dcba

Browse files
authored
Merge pull request #76 from GTBitsOfGood/akash/delete-files
Implemented delete file api route and model
2 parents 1ee15fe + ba0ac3e commit 531dcba

11 files changed

Lines changed: 317 additions & 32 deletions

File tree

‎.github/workflows/update-juno-sdk.yml‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,23 @@ jobs:
1414
run: |
1515
# fetch latest prerelease
1616
latest_prerelease=$(jq -r 'map(select(.prerelease)) | first | .tag_name' <<< "$(curl --silent https://api.github.com/repos/GTBitsOfGood/juno/releases)")
17-
17+
1818
# retrieve auto-generated sdk files
1919
wget "https://github.com/GTBitsOfGood/juno/releases/download/${latest_prerelease}/juno-client-sdk.tar.gz"
20-
20+
2121
# unzip
2222
tar -xvzf "juno-client-sdk.tar.gz"
23-
23+
2424
# move relevant api files over
2525
cp -r juno-client-sdk/api src/internal/
2626
cp -r juno-client-sdk/api.ts src/internal/
2727
cp -r juno-client-sdk/model src/internal/
2828
29-
29+
3030
# cleanup files
3131
rm "juno-client-sdk.tar.gz"
3232
rm -r "juno-client-sdk"
3333
34-
3534
- name: Create Pull Request
3635
uses: peter-evans/create-pull-request@v7
3736
with:

‎README.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
The SDK uses several models to structure the data exchanged between the client and Juno's services. These models represent the input data for API requests and the output data returned by the server.
2828

2929
#### Key Models:
30+
3031
- **CreateProjectModel**: Defines the structure for creating a new project.
3132
- **CreateUserModel**: Contains the necessary fields to create a new user (email, name, password).
3233
- **IssueApiKeyRequest**: Defines the request data for issuing an API key for a project.
@@ -41,6 +42,7 @@ The SDK uses several models to structure the data exchanged between the client a
4142
The SDK includes API methods for interacting with Juno services. These methods abstract the complexities of making HTTP requests and ensure that data is structured according to Juno's requirements.
4243

4344
#### Core APIs:
45+
4446
- **AuthApi**: Handles authentication tasks, such as issuing API keys and generating JWT tokens.
4547
- **EmailApi**: Manages email operations like sending emails and registering domains.
4648
- **ProjectApi**: Manages project-related tasks, including creating projects and linking users.
@@ -51,30 +53,35 @@ The SDK includes API methods for interacting with Juno services. These methods a
5153
The Juno SDK provides a set of APIs for managing various services. Each API is built to simplify interactions with specific Juno infrastructure components. Below is an overview of how to use the main APIs.
5254

5355
### Authentication
56+
5457
The **AuthApi** is used to handle authentication-related tasks, including issuing API keys and generating JWT tokens for secure access to Juno services.
5558

5659
- **Issue API Key**: Create a new API key for project access. This is necessary for authenticating requests to other services.
5760
- **Generate JWT**: Once you have an API key, use it to generate a JWT, which is required to authenticate further API requests.
5861

5962
### Project Management
63+
6064
The **ProjectApi** is responsible for managing projects within Juno’s infrastructure:
6165

6266
- **Create Project**: Define and create a new project using the provided model.
6367
- **Link User to Project**: Associate a user with a project, allowing them to access or contribute to the project.
6468

6569
### User Management
70+
6671
The **UserApi** is designed for creating and managing users:
6772

6873
- **Create User**: Create a new user by providing necessary details like email, name, and password.
6974
- **Set User Role**: Update a user's role to control access levels (e.g., ADMIN, SUPERADMIN).
7075

7176
### Email Management
77+
7278
The **EmailApi** allows you to manage email-related operations, such as registering domains and sending emails. It includes the following functionality:
7379

7480
- **Register Domain**: Register a domain to use as the sender of emails.
7581
- **Send Email**: Send an email through Juno’s email service by specifying the sender, recipient, and content.
7682

7783
### General Workflow
84+
7885
1. **Authentication**: Start by using the **AuthApi** to issue an API key and generate a JWT token.
7986
2. **Project and User Management**: Set up projects and link users using **ProjectApi** and **UserApi**.
8087
3. **Email Operations**: If your project involves email management, use **EmailApi** to register sender domains and send emails.

‎jest.config.js‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
/** @type {import('ts-jest').JestConfigWithTsJest} **/
22
module.exports = {
3-
testEnvironment: "node",
3+
testEnvironment: 'node',
44
transform: {
5-
"^.+.tsx?$": ["ts-jest",{}],
5+
'^.+.tsx?$': ['ts-jest', {}],
66
},
7-
roots: [
8-
"./tests/"
9-
]
7+
roots: ['./tests/'],
108
};

‎src/internal/apis/FileDeleteApi.ts‎

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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 * as runtime from '../runtime';
16+
import type { DeleteFilesModel, DeleteFilesResponse } from '../models/index';
17+
import {
18+
DeleteFilesModelFromJSON,
19+
DeleteFilesModelToJSON,
20+
DeleteFilesResponseFromJSON,
21+
DeleteFilesResponseToJSON,
22+
} from '../models/index';
23+
24+
export interface FileDeleteControllerDeleteFilesRequest {
25+
deleteFilesModel: DeleteFilesModel;
26+
}
27+
28+
/**
29+
*
30+
*/
31+
export class FileDeleteApi extends runtime.BaseAPI {
32+
/**
33+
* Delete files from a bucket
34+
*/
35+
async fileDeleteControllerDeleteFilesRaw(
36+
requestParameters: FileDeleteControllerDeleteFilesRequest,
37+
initOverrides?: RequestInit | runtime.InitOverrideFunction
38+
): Promise<runtime.ApiResponse<DeleteFilesResponse>> {
39+
if (requestParameters['deleteFilesModel'] == null) {
40+
throw new runtime.RequiredError(
41+
'deleteFilesModel',
42+
'Required parameter "deleteFilesModel" was null or undefined when calling fileDeleteControllerDeleteFiles().'
43+
);
44+
}
45+
46+
const queryParameters: any = {};
47+
48+
const headerParameters: runtime.HTTPHeaders = {};
49+
50+
headerParameters['Content-Type'] = 'application/json';
51+
52+
if (this.configuration && this.configuration.accessToken) {
53+
const token = this.configuration.accessToken;
54+
const tokenString = await token('API_Key', []);
55+
56+
if (tokenString) {
57+
headerParameters['Authorization'] = `Bearer ${tokenString}`;
58+
}
59+
}
60+
const response = await this.request(
61+
{
62+
path: `/file/delete`,
63+
method: 'DELETE',
64+
headers: headerParameters,
65+
query: queryParameters,
66+
body: DeleteFilesModelToJSON(requestParameters['deleteFilesModel']),
67+
},
68+
initOverrides
69+
);
70+
71+
return new runtime.JSONApiResponse(response, (jsonValue) =>
72+
DeleteFilesResponseFromJSON(jsonValue)
73+
);
74+
}
75+
76+
/**
77+
* Delete files from a bucket
78+
*/
79+
async fileDeleteControllerDeleteFiles(
80+
requestParameters: FileDeleteControllerDeleteFilesRequest,
81+
initOverrides?: RequestInit | runtime.InitOverrideFunction
82+
): Promise<DeleteFilesResponse> {
83+
const response = await this.fileDeleteControllerDeleteFilesRaw(
84+
requestParameters,
85+
initOverrides
86+
);
87+
return await response.value();
88+
}
89+
}

‎src/internal/apis/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export * from './AuthApi';
66
export * from './EmailApi';
77
export * from './FileBucketApi';
88
export * from './FileConfigApi';
9+
export * from './FileDeleteApi';
910
export * from './FileDownloadApi';
1011
export * from './FileProviderApi';
1112
export * from './FileUploadApi';
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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 DeleteFilesModel
20+
*/
21+
export interface DeleteFilesModel {
22+
/**
23+
* Name of the bucket containing the files
24+
* @type {string}
25+
* @memberof DeleteFilesModel
26+
*/
27+
bucketName: string;
28+
/**
29+
* Configuration ID for the bucket
30+
* @type {number}
31+
* @memberof DeleteFilesModel
32+
*/
33+
configId: number;
34+
/**
35+
* List of file names to delete
36+
* @type {Array<string>}
37+
* @memberof DeleteFilesModel
38+
*/
39+
fileNames: Array<string>;
40+
}
41+
42+
/**
43+
* Check if a given object implements the DeleteFilesModel interface.
44+
*/
45+
export function instanceOfDeleteFilesModel(
46+
value: object
47+
): value is DeleteFilesModel {
48+
if (!('bucketName' in value) || value['bucketName'] === undefined)
49+
return false;
50+
if (!('configId' in value) || value['configId'] === undefined) return false;
51+
if (!('fileNames' in value) || value['fileNames'] === undefined) return false;
52+
return true;
53+
}
54+
55+
export function DeleteFilesModelFromJSON(json: any): DeleteFilesModel {
56+
return DeleteFilesModelFromJSONTyped(json, false);
57+
}
58+
59+
export function DeleteFilesModelFromJSONTyped(
60+
json: any,
61+
ignoreDiscriminator: boolean
62+
): DeleteFilesModel {
63+
if (json == null) {
64+
return json;
65+
}
66+
return {
67+
bucketName: json['bucketName'],
68+
configId: json['configId'],
69+
fileNames: json['fileNames'],
70+
};
71+
}
72+
73+
export function DeleteFilesModelToJSON(value?: DeleteFilesModel | null): any {
74+
if (value == null) {
75+
return value;
76+
}
77+
return {
78+
bucketName: value['bucketName'],
79+
configId: value['configId'],
80+
fileNames: value['fileNames'],
81+
};
82+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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 DeleteFilesResponse
20+
*/
21+
export interface DeleteFilesResponse {
22+
/**
23+
* The name of the bucket from which files were deleted
24+
* @type {string}
25+
* @memberof DeleteFilesResponse
26+
*/
27+
bucketName: string;
28+
/**
29+
* List of file names that were deleted
30+
* @type {Array<string>}
31+
* @memberof DeleteFilesResponse
32+
*/
33+
fileNames: Array<string>;
34+
}
35+
36+
/**
37+
* Check if a given object implements the DeleteFilesResponse interface.
38+
*/
39+
export function instanceOfDeleteFilesResponse(
40+
value: object
41+
): value is DeleteFilesResponse {
42+
if (!('bucketName' in value) || value['bucketName'] === undefined)
43+
return false;
44+
if (!('fileNames' in value) || value['fileNames'] === undefined) return false;
45+
return true;
46+
}
47+
48+
export function DeleteFilesResponseFromJSON(json: any): DeleteFilesResponse {
49+
return DeleteFilesResponseFromJSONTyped(json, false);
50+
}
51+
52+
export function DeleteFilesResponseFromJSONTyped(
53+
json: any,
54+
ignoreDiscriminator: boolean
55+
): DeleteFilesResponse {
56+
if (json == null) {
57+
return json;
58+
}
59+
return {
60+
bucketName: json['bucketName'],
61+
fileNames: json['fileNames'],
62+
};
63+
}
64+
65+
export function DeleteFilesResponseToJSON(
66+
value?: DeleteFilesResponse | null
67+
): any {
68+
if (value == null) {
69+
return value;
70+
}
71+
return {
72+
bucketName: value['bucketName'],
73+
fileNames: value['fileNames'],
74+
};
75+
}

‎src/internal/models/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export * from './CustomEventTypeResponse';
1313
export * from './CustomGraphType';
1414
export * from './CustomGraphTypeResponse';
1515
export * from './DeleteFileBucketModel';
16+
export * from './DeleteFilesModel';
17+
export * from './DeleteFilesResponse';
1618
export * from './DownloadFileModel';
1719
export * from './DownloadFileResponse';
1820
export * from './EmailConfigResponse';

0 commit comments

Comments
 (0)